File pinball.spec of Package pinball

#
# spec file for package pinball
#
# Copyright (c) 2021 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


Name:           pinball
Version:        0.3.1
Release:        0
Summary:        Emilia Pinball Emulator
License:        GPL-2.0-only
Group:          Amusements/Games/Action/Arcade
URL:            http://pinball.sourceforge.net/
Source0:        http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Source1:        pinball.desktop
Source2:        pinball-16x16.png
Source3:        pinball-32x32.png
Source4:        pinball-48x48.png
Patch0:         pinball-0.3.1-sys-ltdl.patch
Patch1:         pinball-0.3.1-strictproto.patch
Patch2:         pinball-0.3.1-lacomment.patch
Patch3:         pinball-0.3.1-cstddef.patch
Patch4:         0001-Do-not-return-pointer-to-temporary.patch
Patch5:         fix_make_dependency_order.patch
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  libtool
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(SDL_image)
BuildRequires:  pkgconfig(SDL_mixer)
%if 0%{?suse_version} >= 1500
Requires(pre):  user(games)
Requires(pre):  group(games)
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%global _lto_cflags %{?_lto_cflags} -ffat-lto-objects

%description
The Emilia Pinball Project is a pinball simulator for Linux and other
Unix systems. There are only two levels to play with, but they are very
addictive.

%package devel
Summary:        Developemnt files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
Development files for %{name}.

%prep
%setup -q
%patch0 -p1
%patch1
%patch2 -p1
%patch3
%patch4 -p1
%patch5
rm -fr libltdl

%build
# update libtool to distro version, bundled one breaks when libpthread is a linker script
autoreconf -i -f
%configure \
    --disable-static \
    --disable-libtest \
    --disable-sdltest
%__make %{?_smp_mflags} VERBOSE=1 CXXFLAGS="%{optflags}"

%install
%make_install
chmod -x ChangeLog
install -Dm 0644 %{SOURCE1} \
    %{buildroot}%{_datadir}/applications/%{name}.desktop
install -Dm 0644 %{SOURCE2} \
    %{buildroot}%{_datadir}/icons/hicolor/16x16/apps/%{name}.png
install -Dm 0644 %{SOURCE3} \
    %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
install -Dm 0644 %{SOURCE4} \
    %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
# remove unused test module
rm %{buildroot}%{_libdir}/%{name}/libModuleTest.*
# ltdl can use native (.so) libs, but we have to fix the name in the pinball definition
for pbl in %{buildroot}%{_datadir}/%{name}/*/*.pbl; do
    sed -i -e 's#\(libModule.*\).la#\1.so.0#' $pbl && echo "Patched $pbl"
done
# remove unused pcx files (only used by alternative Allegro backend)
rm %{buildroot}%{_datadir}/%{name}/*.pcx
rm %{buildroot}%{_datadir}/%{name}/*/*.pcx
# remove bogus development files
rm %{buildroot}%{_libdir}/%{name}/lib*.{la,a}
%fdupes -s %{buildroot}%{_datadir}/%{name}/

%post
%icon_theme_cache_post

%postun
%icon_theme_cache_postun

%files
%defattr(-,root,root,-)
%doc ChangeLog README
%license COPYING
%{_bindir}/%{name}
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/lib*.0
%{_datadir}/%{name}/
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/*/%{name}.*
%dir %{_localstatedir}/games/
%dir %{_localstatedir}/games/%{name}/
%dir %attr(0775,games,games) %{_localstatedir}/games/%{name}/*/
%ghost %attr(0664,games,games) %{_localstatedir}/games/%{name}/*/highscores

%files devel
%license COPYING
%{_includedir}/%{name}/
%{_libdir}/%{name}/lib*.so
%{_bindir}/%{name}-config

%changelog
openSUSE Build Service is sponsored by