File tesseract.spec of Package tesseract

#
# spec file for package tesseract
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define edition first

Name:           tesseract
Version:        2014_05_12
Release:        0
Url:            http://tesseract.gg/
Summary:        Open Source FPS with cooperative in-game map editing
License:        Zlib
Group:          Amusements/Games/3D/Shoot
Source:         http://download.tuxfamily.org/tesseract/%{name}_%{version}_%{edition}_edition_linux.tar.xz
Source1:        tesseract.desktop
Source2:        tesseract.png
BuildRequires:  Mesa-devel
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(SDL2_image)
BuildRequires:  pkgconfig(SDL2_mixer)
BuildRequires:  pkgconfig(zlib)
Requires:       %{name}-data = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Tesseract is a first-person shooter game focused on instagib deathmatch
and capture-the-flag gameplay as well as cooperative in-game map editing.

Tesseract provides a unique open-source engine derived from Cube 2:
Sauerbraten technology but with upgraded modern rendering techniques.
The new rendering features include fully dynamic omnidirectional shadows,
global illumination, HDR lighting, deferred shading,
morphological/temporal/multisample anti-aliasing, and much more.

%package server
Summary:        Tesseract standalone server
Group:          Amusements/Games/3D/Shoot

%description server
This package provides the server files for Tesseract

%package data
Summary:        Data files for Tesseract
Group:          Amusements/Games/3D/Shoot
Requires:       %{name} = %{version}
BuildArch:      noarch

%description data
This package provides the data files for Tesseract

%prep
%setup -q -n %{name}

%build
rm -r bin_unix
mkdir -p bin_unix
cd src
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
make CXXOPTFLAGS="-Wall -fsigned-char %{optflags}"
make install
cd ../bin_unix
mv *client client
mv *server server

%install
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a bin_unix %{buildroot}%{_libexecdir}/%{name}
mkdir -p %{buildroot}%{_bindir}
cat <<EOT >%{buildroot}%{_bindir}/%{name}-game
#!/bin/sh
TESSERACT_DIR=\$HOME/.tesseract
if test ! -e \$TESSERACT_DIR ; then
    mkdir \$TESSERACT_DIR
    ln -s %{_libexecdir}/%{name}/* \$TESSERACT_DIR
fi
cd \$TESSERACT_DIR
exec bin_unix/client "\$@"
EOT
chmod 755 %{buildroot}%{_bindir}/%{name}-game
ln -sf ../lib/%{name}/bin_unix/server %{buildroot}%{_bindir}/%{name}-server

# copy data files
cp -a media/ config/ %{buildroot}%{_libexecdir}/tesseract/

# .desktop shortcut and icon
install -d %{buildroot}%{_datadir}/applications
cp %{SOURCE1} %{buildroot}%{_datadir}/applications

install -d %{buildroot}%{_datadir}/icons/hicolor/64x64/apps/
cp %{SOURCE2} %{buildroot}%{_datadir}/icons/hicolor/64x64/apps/

%fdupes -s %{buildroot}%{_libexecdir}/tesseract/media/

%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun

%files
%defattr(-,root,root)
%{_bindir}/%{name}-game
%dir %{_libexecdir}/%{name}
%dir %{_libexecdir}/%{name}/bin_unix
%{_libexecdir}/%{name}/bin_unix/client
%{_datadir}/applications/tesseract.desktop
%{_datadir}/icons/hicolor/64x64/apps/tesseract.png

%files server
%defattr(-,root,root)
%{_bindir}/%{name}-server
%dir %{_libexecdir}/%{name}/bin_unix
%{_libexecdir}/%{name}/bin_unix/server

%files data
%defattr(-,root,root)
%doc doc/dev/*
%dir %{_libexecdir}/tesseract
%{_libexecdir}/tesseract/media
%{_libexecdir}/tesseract/config

%changelog
openSUSE Build Service is sponsored by