Name: supertuxkart
Version: 0.8.1
Release: 1%{?_dist_release}
Summary: An enhanced version of TuxKart, a kart racing game
Summary(ja): TuxKart を拡張したカートレーシングゲーム

License: GPLv2+ and GPLv3 and CC-BY-SA
Group: Applications/Games
URL: http://supertuxkart.sourceforge.net/

Source0: http://download.sourceforge.net/%{name}/%{name}-%{version}-src.tar.bz2
Source2: supertuxkart-0.7.3-license-clarification.txt

Patch0:  supertuxkart-fhs.patch
# tracked in github.com/ignatenkobrain/stk-code/ in fedora-0.8.1 branch
Patch1:  0001-fix-.desktop-file-and-install-destinations.patch
#Patch2: 0002-unbundle-bullet.patch
Patch3:  0003-unbundle-enet.patch
Patch4:  0004-unbundle-irrlicht.patch
Patch5:  0005-unbundle-wiiuse.patch
Patch6:  0006-Adding-a-Wiimote-with-other-one-alredy-placed-Bug-12.patch
Patch7:	 supertuxkart-mesa-fix.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: cmake
BuildRequires: libvorbis-devel freeglut-devel desktop-file-utils
BuildRequires: openal-soft-devel freealut-devel libtool
BuildRequires: curl-devel
#BuildRequires: enet-devel
BuildRequires: fribidi-devel
#BuildRequires: wiiuse-devel
BuildRequires: bluez-libs-devel
#BuildRequires: irrlicht-devel

%global _privatelibs lib(stkirrlicht|wiiuse)[.]so.*
%global __provides_exclude ^(%{_privatelibs})$
%global __requires_exclude ^(%{_privatelibs})$

%description
SuperTuxKart is an enhanced version of TuxKart, a kart racing game,
originally done by Steve Baker, featuring Tux and a bunch of his
friends.

%description -l ja
SuperTuxKart は TuxKart を拡張したカートレーシングゲームです。


%prep
%setup -q -n SuperTuxKart-%{version}
%patch0 -p1
%patch1 -p1
#patch2 -p1
#patch3 -p1
#patch4 -p1
#patch5 -p1
%patch7 -p0

cp -p %{SOURCE2} .

# Delete bundled libs
#rm -rf lib/irrlicht

%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
%cmake \
    ..
popd
make %{?_smp_mflags} -C %{_target_platform}
#LDFLAGS=-lGLU irrlicht_LIBS="-lIrrlicht -lIrrXML"

%install
rm -rf $RPM_BUILD_ROOT
cd %{_target_platform}
make DESTDIR=$RPM_BUILD_ROOT install 

mkdir -p $RPM_BUILD_ROOT%{_libdir}
install -m755 lib/irrlicht/libstkirrlicht.so $RPM_BUILD_ROOT%{_libdir}/libstkirrlicht.so
install -m755 lib/wiiuse/libwiiuse.so $RPM_BUILD_ROOT%{_libdir}/libwiiuse.so

cd ..

# fix .desktop file
desktop-file-install \
    --dir $RPM_BUILD_ROOT%{_datadir}/applications \
    --remove-key=Exec \
    --set-key=Exec --set-value='%{_bindir}/supertuxkart --no-console'  \
    $RPM_BUILD_ROOT%{_datadir}/applications/supertuxkart.desktop

## remove unpackaged files
#__rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}

%clean
rm -rf $RPM_BUILD_ROOT

%check
desktop-file-validate %{buildroot}%{_datadir}/applications/*%{name}.desktop

%post
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
/sbin/ldconfig

%postun
if [ $1 -eq 0 ] ; then
    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
/sbin/ldconfig

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :


%files
%defattr(-,root,root)
%doc AUTHORS COPYING README TODO
%doc supertuxkart-0.7.3-license-clarification.txt
%{_bindir}/supertuxkart
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/supertuxkart
%{_libdir}/libstkirrlicht.so
%{_libdir}/libwiiuse.so

%changelog
* Wed Feb  4 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.8.1-1
- updated to 0.8.1
- built without current irrlicht
- added SOURCE2 from Fedora

* Sun Jun 24 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.7-2
- change BuildRequires: libmikmod-devel instead of mikmod-devel

* Wed Mar 16 2011 Kazutaka HARADA <kazutaka@vinelinux.org> 0.7-1
- new upstream release
- add BuildRequires: irrlicht-devel fribidi-devel

* Fri Oct 09 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.6.2-1
- new upstream release
- changed URL: to http://supertuxkart.sourceforge.net/

* Thu Jul 30 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.6.1a-2
- added Japanese Summary and description

* Fri May 08 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.6.1a-1
- new upstream release
- added BuildRequires: libvorbis-devel

* Sun Jan 25 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.6-1
- new upstream release

* Mon Nov 24 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.5-3
- s|/usr/games/supertuxkart|/usr/bin/supertuxkart|g in supertuxkart.desktop

* Wed Oct 22 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.5-2vl5
- added BuildRequires: freeglut-devel

* Sat Oct 11 2008 Shu KONNO <owa@bg.wakwak.com> 0.5-1vl5
- new upstream release
- applied new versioning policy

* Sat Feb 9 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.3-0vl2
- rebuild for VineSeed

* Sun Aug 5 2007 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 0.3-0vl1
- initial build for Vine Linux 4.1
