File openttd.spec of Package openttd

#
# spec file for package openttd
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2007-2012 The OpenTTD developers
#
# 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/
#


Name:           openttd
Version:        1.5.3
Release:        0
Summary:        An open source clone of Chris Sawyer's Transport Tycoon Deluxe
License:        GPL-2.0
Group:          Amusements/Games/Strategy/Other
Url:            http://www.openttd.org
Source:         http://binaries.openttd.org/releases/%{version}/%{name}-%{version}-source.tar.xz
Patch0:         openttd-gcc5.patch
BuildRequires:  SDL-devel
BuildRequires:  fontconfig-devel
BuildRequires:  gcc-c++
BuildRequires:  libicu-devel
BuildRequires:  libpng-devel
BuildRequires:  pkgconfig
BuildRequires:  xz
BuildRequires:  zlib-devel
%if 0%{?mdkversion}
BuildRequires:  liblzma-devel
BuildRequires:  liblzo-devel
%else
BuildRequires:  lzo-devel
BuildRequires:  xz-devel
%endif
%if 0%{?suse_version} || 0%{?mdkversion}
BuildRequires:  freetype2-devel
%else
BuildRequires:  freetype-devel
%endif
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(libtimidity)
BuildRequires:  pkgconfig(libxdg-basedir)
%else
BuildRequires:  desktop-file-utils
BuildRequires:  grfcodec
Requires:       hicolor-icon-theme
%endif
%if 0%{?suse_version} || 0%{?mdkversion}
Recommends:     openttd-openmsx
Recommends:     openttd-opensfx
Recommends:     adobe-sourcehansans-fonts
%endif
Requires:       %{name}-data = %{version}-%{release}
Conflicts:      %{name}-dedicated
Provides:       %{name}-gui = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%define about OpenTTD is a reimplementation of the Microprose game "Transport Tycoon Deluxe" with lots of new features and enhancements. To play the game you need either the original data from the game or install the recommend subackages OpenGFX for free graphics, OpenSFX for free sounds and OpenMSX for free music.

%description
%about

Use package %{name}-dedicated for systems without SDL.

%package dedicated
Summary:        OpenTTD Dedicated Server binary (without SDL)
Group:          Amusements/Games/Strategy/Other

Requires:       %{name}-data = %{version}-%{release}
Conflicts:      %{name}

%description dedicated
%about

This package provides the binary %{name}-dedicated without dependency of SDL.

%package data
Summary:        OpenTTD data
Group:          Amusements/Games/Strategy/Other
%if 0%{?suse_version} > 1110 || 0%{?fedora} || 0%{?mdkversion} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
BuildArch:      noarch
%endif
%if 0%{?suse_version} || 0%{?mdkversion}
Recommends:     openttd-opengfx >= 0.5.2
%endif

%description data
%about

This package provides the data files needed by %{name} or %{name}-dedicated.

%prep
%setup -qn %{name}-%{version}
%patch0 -p1

# Remove build time references so build-compare can do its work
sed -i "s/__DATE__/\"openSUSE\"/" src/rev.cpp.in
sed -i "s/__TIME__/\"BuildService\"/" src/rev.cpp.in
sed -i "s/!!DATE!!/openSUSE Build Service/" src/rev.cpp.in

%build
# first, we build the dedicated binary and copy it to dedicated/
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
CFLAGS_BUILD="$RPM_OPT_FLAGS" CXXFLAGS_BUILD="$RPM_OPT_FLAGS" \
./configure \
        --disable-strip \
        --prefix-dir="%{_prefix}" \
        --binary-dir="bin" \
        --data-dir="share/%{name}" \
        --enable-dedicated
make %{?_smp_mflags} bundle BUNDLE_DIR="dedicated" VERBOSE=1

make distclean
# then, we build the common gui version which we install the usual way
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
CFLAGS_BUILD="$RPM_OPT_FLAGS" CXXFLAGS_BUILD="$RPM_OPT_FLAGS" \
./configure \
        --disable-strip \
        --prefix-dir="%{_prefix}" \
        --binary-name="%{name}" \
        --binary-dir="bin" \
        --data-dir="share/%{name}" \
        --doc-dir="share/doc/%{name}" \
        --menu-name="OpenTTD" \
        --menu-group="Game;StrategyGame;"

make %{?_smp_mflags} VERBOSE=1

%install
# install the dedicated binary
install -D -m0755 dedicated/openttd %{buildroot}%{_bindir}/%{name}-dedicated
# install the gui binary
make install INSTALL_DIR=%{buildroot} VERBOSE=1

%if 0%{?suse_version}
%suse_update_desktop_file -r %{name} Game StrategyGame
%else
%if 0%{?fedora} || 0%{?mdkversion} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
desktop-file-install --dir=%{buildroot}%{_datadir}/applications \
        --add-category=StrategyGame \
        media/openttd.desktop
%endif
%endif

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

%post dedicated
rm -f %{_bindir}/%{name}
ln -s %{name}-dedicated %{_bindir}/%{name}

%preun dedicated
if [ "$1" -eq 0 ] ; then
    rm -f %{_bindir}/%{name}
fi

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

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

%files
%defattr(-, root, root)
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor
%{_datadir}/pixmaps/%{name}.32.xpm
%{_mandir}/man6/%{name}.6.*

%files dedicated
%defattr(-, root, root)
%{_bindir}/%{name}-dedicated

%files data
%defattr(-, root, root)
%{_datadir}/doc/%{name}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/lang
%{_datadir}/%{name}/baseset
%{_datadir}/%{name}/scripts
%{_datadir}/%{name}/ai
%{_datadir}/%{name}/game

%changelog
openSUSE Build Service is sponsored by