Name:           irrlicht
Summary:        A high performance and free realtime 3D engine
Version:        1.8.5
Release:        1
License:        zlib
URL:            http://irrlicht.sourceforge.net/
Source0:        http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.5.zip
Patch0001:      irrlicht-1.8-optflags.patch
Patch0002:      irrlicht-1.8-glext.patch
Patch0003:      irrlicht18-libaesgm.patch
Patch0004:      irrlicht-1.8-irrXML-shared-library.patch
Patch0005:      irrlicht-1.8-fix-locale-decimal-points.patch
BuildRequires:  gcc-c++ libXxf86vm-devel mesa-libGL-devel mesa-libGLU-devel
BuildRequires:  libjpeg-devel zlib-devel libaesgm-devel libpng-devel  bzip2-devel
Provides:       irrlicht18 = %{version}-%{release}
Obsoletes:      irrlicht18 <= 1.8-0.4.svn3629

%description
The Irrlicht Engine is an open source high performance realtime 3D engine
written and usable in C++ and also available for .NET languages.

%package devel
Summary:        Development header files and libraries for irrlicht
Requires:       irrlicht = %{version}-%{release} mesa-libGL-devel mesa-libGLU-devel
Requires:       libjpeg-devel zlib-devel libpng-devel libXxf86vm-devel irrXML-devel = 1.8.5
Provides:       irrlicht18-devel = %{version}-%{release}
Obsoletes:      irrlicht18-devel <= 1.8-0.4.svn3629

%description devel
Development header files and libraries for irrlicht.

%package -n irrXML
Summary:        Simple and fast XML parser for C++
Version:        1.8.5
Provides:       irrXML18 = 1.8.5-%{release}
Obsoletes:      irrXML18 <= 1.8-0.4.svn3629

%description -n irrXML
This package provides a simple and fast open source xml parser for C++.

%package -n irrXML-devel
Summary:        Development header files and libraries for irrXML
Version:        1.8.5
Requires:       irrXML = 1.8.5-%{release}
Provides:       irrXML18-devel = 1.8.5-%{release}
Obsoletes:      irrXML18-devel <= 1.8-0.4.svn3629

%description -n irrXML-devel
Development header files and libraries for irrXML.

%prep
%autosetup -n %{name}-%{version} -p1

sed -i 's|VERSION_RELEASE = 0|VERSION_RELEASE = 1|g' source/Irrlicht/Makefile
rm -rf source/Irrlicht/jpeglib source/Irrlicht/zlib source/Irrlicht/libpng source/Irrlicht/aesGladman

for i in include/*.h doc/upgrade-guide.txt source/Irrlicht/*.cpp source/Irrlicht/*.h; do
         sed -i 's/\r//' $i;chmod -x $i;touch -r changes.txt $i
done

sed -i -e '/_IRR_MATERIAL_MAX_TEXTURES_/s/4/8/' include/IrrCompileConfig.h

%build
cd source/Irrlicht
%make_build  sharedlib

%install
install -d %{buildroot}%{_libdir}
install -d %{buildroot}%{_includedir}/irrlicht
make -C source/Irrlicht INSTALL_DIR=%{buildroot}%{_libdir} install
cp -a include/*.h %{buildroot}%{_includedir}/irrlicht/
pushd %{buildroot}%{_libdir}
ln -s libIrrlicht.so.1.8.5 libIrrlicht.so.1
ln -s libIrrXML.so.1.8.5 libIrrXML.so.1
popd

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

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

%files
%doc readme.txt
%{_libdir}/libIrrlicht.so.*
%{_libdir}/libIrrXML.so*

%files devel
%doc doc/upgrade-guide.txt
%{_includedir}/irrlicht/
%exclude %{_includedir}/irrlicht/{fast_atof.h,heapsort.h,irrArray.h}
%exclude %{_includedir}/irrlicht/{irrString.h,irrTypes.h,irrXML.h}
%{_libdir}/libIrrlicht.so

%files -n irrXML
%doc readme.txt

%files -n irrXML-devel
%dir %{_includedir}/irrlicht/
%{_includedir}/irrlicht/{fast_atof.h,heapsort.h,irrArray.h,irrString.h,irrTypes.h,irrXML.h}

%changelog
* Tue Oct 17 2023 wulei <wu_lei@hoperun.com> - 1.8.5-1
- Update to 1.8.5

* Sat Jun 26 2021 wangyue<wangyue92@huawei.com> - 1.8.4-12
- Remove sysctl.h to fix build error

* Mon Mar 09 2020 xuxijian<xuxijian@huawei.com> - 1.8.4-11
- Add libIrrXML patch files

* Tue Feb 25 2020 xuxijian<xuxijian@huawei.com> - 1.8.4-10
- Package init
