File uqm.spec of Package uqm

#
# spec file for package uqm
#
# 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/
#


%define oversion 0.8.0-1
Name:           uqm
Version:        0.8.0
Release:        0
Summary:        The Ur-Quan Masters, a port of the classic game Star Control II
License:        GPL-2.0-or-later
Group:          Amusements/Games/Action/Shoot
URL:            https://sc2.sourceforge.net/
Source0:        https://sourceforge.net/projects/sc2/files/UQM/0.8/uqm-%{version}-src.tgz
Source1:        config.state
Source2:        %{name}.desktop
Source3:        %{name}.png
# PATCH-FIX-OPENSUSE uqm-build-vars-lm.patch - hack to add -lm to the linker commandline
# Patch0:         uqm-build-vars-lm.patch
BuildRequires:  Mesa-devel
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  libmikmod-devel
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(SDL2_image)
BuildRequires:  pkgconfig(openal)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(sdl2)
BuildRequires:  pkgconfig(vorbis)
BuildRequires:  pkgconfig(zlib)
Requires:       %{name}-content >= 0.7

%description
The Ur-Quan Masters is a port of the classic game Star Control II to
modern systems.  The program code that comprises The Ur-Quan Masters
was derived from code written by Toys for Bob, Inc. for the 3DO
version of Star Control II, with their permission and encouragement.

%prep
%autosetup -p1

# use config.state to configure build options
cp %{SOURCE1} .
./build.sh uqm reprocess_config

# Replace build time references with fake ones so build-compare can do its work
FAKE_BUILDTIME=$(LC_ALL=C date -u -r %{_sourcedir}/%{name}.changes '+%%H:%%M')
FAKE_BUILDDATE=$(LC_ALL=C date -u -r %{_sourcedir}/%{name}.changes '+%%b %%e %%Y')
sed -i "s/__TIME__/\"$FAKE_BUILDTIME\"/" src/uqm.c
sed -i "s/__DATE__/\"$FAKE_BUILDDATE\"/" src/uqm.c

# fix build (taken from Fedora)
cd src/uqm/comm/
for d in */ ; do
   cd $d
   mv strings.h ustrings.h
   cd ..
done
find . -type f -name '*.c' | xargs sed -i s/strings.h/ustrings.h/g
find . -type f -name '*.h' | xargs sed -i s/STRINGS/USTRINGS/g

%build
./build.sh uqm

%install
# binary
install -dm 755 %{buildroot}%{_bindir}
install -m 755 %{name} %{buildroot}%{_bindir}/%{name}

# uqm data dir
install -dm 755 %{buildroot}%{_datadir}/%{name}/content/packages
# uqm addon dir
install -dm 755 %{buildroot}%{_datadir}/%{name}/content/addons
# without the version file uqm do not start
echo %{version} > %{buildroot}%{_datadir}/%{name}/content/version

# menu
install -dm 755 %{buildroot}%{_datadir}/applications
install -m 644 %{SOURCE2} %{buildroot}%{_datadir}/applications

# icon
install -dm 755 %{buildroot}%{_datadir}/pixmaps
install -m 644 %{SOURCE3} %{buildroot}%{_datadir}/pixmaps

%suse_update_desktop_file -r %{name} Game ActionGame

%files
%license COPYING
%doc AUTHORS ChangeLog Contributing README WhatsNew
%doc doc/users/manual.txt
%{_bindir}/uqm
%{_datadir}/uqm/
%{_datadir}/applications/uqm.desktop
%{_datadir}/pixmaps/uqm.png

%changelog
openSUSE Build Service is sponsored by