File ufoai.spec of Package ufoai

#
# spec file for package ufoai
#
# Copyright (c) 2023 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 build_tar_ball 1
Name:           ufoai
Version:        2.5+git20230421.7c4ccd5f9d
Release:        0
Summary:        Turn-based squad-based tactical strategy game fighting aliens
License:        GPL-2.0-or-later
Group:          Amusements/Games/Strategy/Turn Based
URL:            https://ufoai.org/
%if %{build_tar_ball}
Source0:        %{name}-%{version}.tar.bz2
%else
Source0:        _service
%endif
Source1:        %{name}.desktop
Source2:        %{name}.6
Source3:        ufo2map.1
Source4:        ufomodel.1
Source5:        ufoslicer.1
Source6:        ufoai-rpmlintrc
Source99:       %{name}.changes
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  zip
BuildRequires:  pkgconfig(SDL2_mixer)
BuildRequires:  pkgconfig(SDL2_ttf)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(lua) >= 5.3
BuildRequires:  pkgconfig(mxml)
BuildRequires:  pkgconfig(ogg)
BuildRequires:  pkgconfig(vorbis)

Requires:       %{name}-common = %{version}
Requires:       %{name}-data >= 2.5
Requires:       %{name}-maps >= 2.5
Recommends:     %{name}-music >= 2.5
Suggests:       %{name}-server >= 2.5
Suggests:       %{name}-doc >= 2.5

%package common
Summary:        UFO:AI - game Library and shared files

%package devel
Summary:        UFO:AI - developer tools and documentation
Group:          Development/Tools/Other
BuildRequires:  doxygen
BuildRequires:  graphviz-gd

%package server
Summary:        UFO:AI - dedicated game server
Requires:       %{name}-common = %{version}
Requires:       %{name}-maps >= 2.5

%package doc
Summary:        UFO:AI - user manual
Group:          Documentation/Other
License:        GFDL-1.2-or-later
BuildArch:      noarch
BuildRequires:  tex(anysize.sty)
BuildRequires:  tex(pdfsync.sty)
BuildRequires:  tex(scrartcl.cls)

%description
UFO: ALIEN INVASION is a strategy game featuring tactical combat
against hostile alien forces which are about to infiltrate earth at
this very moment. You are in command of a small special unit which
has been founded to face the alien strike force. To be successful on
the long run, you will also have to have a research team study the
aliens and their technologies in order to learn as much as possible
about their technology, their goals and the aliens themselves.

%description common
UFO: ALIEN INVASION is a strategy game featuring tactical combat
against hostile alien forces which are about to infiltrate earth at
this very moment.

This package contains a game library and shared files.

%description devel
UFO: ALIEN INVASION is a strategy game featuring tactical combat
against hostile alien forces which are about to infiltrate earth at
this very moment.

This package contains generated source code documentation and
developer tools:
 * ufo2map - maps compiler
 * ufomodel - tool to modify and optimize model files
 * ufoslicer - tool to slice map files

%description server
UFO: ALIEN INVASION is a strategy game featuring tactical combat
against hostile alien forces which are about to infiltrate earth at
this very moment.

This package contains the dedicated game server.

%description doc
UFO: ALIEN INVASION is a strategy game featuring tactical combat
against hostile alien forces which are about to infiltrate earth at
this very moment.

This package contains the user manual for the game.

%lang_package

%prep
%if %{build_tar_ball}
%setup -q
%else
%setup -q -n %_sourcedir/%name-%version -T -D
%endif

# Fix file-contains-date-and-time
modified="$(sed -n '/^----/n;s/ - .*$//;p;q' "%{SOURCE99}")"
DATE="\"$(date -d "${modified}" "+%%b %%e %%Y")\""
TIME="\"$(date -d "${modified}" "+%%R")\""
find . -name '*.h' -o -name '*.cpp' -print0 |\
xargs -0 %__sed -i "s/__DATE__/${DATE}/g;s/__TIME__/${TIME}/g"
# Adapt desktop file
%__sed -i 's:/usr/games/ufoded:ufoded:g;s:ufoded.xpm:ufoded:g' \
debian/ufoded.desktop
# Add shebang to Blender scripts
%__sed -i '1 i #!/usr/bin/env python' src/tools/blender/*.py

%build
# not an autoconf-style configure
./configure --prefix=%{_prefix} \
            --bindir=%{_bindir} \
            --datadir=%{_datadir}/%{name} \
            --libdir=%{_libdir}/%{name} \
            --localedir=%{_datarootdir}/locale \
            --disable-uforadiant \
            --disable-testall \
%ifarch x86_64 i586
            --enable-sse \
%endif
            --enable-release
%make_build all lang manual doxygen-docs pk3 PAK_FILES="0base.pk3 0ufos.pk3"

# Remove timestamp from HTML docs
find src/docs/doxygen/html -name '*.html' -print0 |\
xargs -0 %__sed -i 's/\bGenerated on\b.*\bfor UFO: Alien Invasion by\b/Generated on __DATE__ __TIME__ for UFO: Alien Invasion by/'

%install
%__install -sD ufo %{buildroot}%{_bindir}/%{name}
%__install -sD base/game.so %{buildroot}%{_libdir}/%{name}/game.so
%__install -D -m 0644 -t %{buildroot}%{_datadir}/%{name}/base \
base/{0base,0ufos}.pk3
%__cp -pr base/i18n %{buildroot}%{_datadir}/locale
%__install -st %{buildroot}%{_bindir} ufoded ufo2map ufomodel ufoslicer

# Manuals
%__install -D -m 0644 -t %{buildroot}%{_docdir}/%{name} \
src/docs/tex/ufo-manual_EN.pdf
%__cp -pr src/docs/doxygen/html %{buildroot}%{_docdir}/%{name}/html
%fdupes -s %{buildroot}%{_docdir}/%{name}/html

# Optional dev stuff
%__mkdir %{buildroot}%{_datadir}/%{name}/tools
%__cp -prt %{buildroot}%{_datadir}/%{name}/tools src/tools/blender \
contrib/vim
%__install -D -m 0644 -t %{buildroot}%{_datadir}/bash_completion.d contrib/\
scripts/bashcompletion/{ufo2map,ufomodel}

# desktop files, icons
%__install -D -m 0644 -t %{buildroot}%{_datadir}/applications %{SOURCE1} \
debian/ufoded.desktop
%__install -D -m 0644 -t %{buildroot}%{_datadir}/icons/hicolor/32x32/apps \
debian/{%{name},ufoded}.xpm
%__install -D -m 0644 -t %{buildroot}%{_mandir}/man6 %{SOURCE2} \
debian/ufoded.6
%__install -D -m 0644 -t %{buildroot}%{_mandir}/man1 %{SOURCE3} %{SOURCE4} \
%{SOURCE5}

%find_lang %{name}

%files
%dir %{_datadir}/%{name}
%{_bindir}/%{name}
%{_mandir}/man6/%{name}.6%{?ext_man}
%{_datadir}/icons/hicolor/32x32/apps/%{name}.xpm
%{_datadir}/applications/%{name}.desktop
%license COPYING

%files common
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/32x32
%dir %{_datadir}/icons/hicolor/32x32/apps
%{_libdir}/%{name}
%{_datadir}/%{name}/base

%files devel
%{_bindir}/{ufo2map,ufomodel,ufoslicer}
%{_mandir}/man1/{ufo2map.1,ufomodel.1,ufoslicer.1}%{?ext_man}
%{_datadir}/%{name}/tools
%{_datadir}/bash_completion.d
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/html

%files server
%{_bindir}/ufoded
%{_mandir}/man6/ufoded.6%{?ext_man}
%{_datadir}/icons/hicolor/32x32/apps/ufoded.xpm
%{_datadir}/applications/ufoded.desktop

%files doc
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/ufo-manual_EN.pdf

%if %{build_tar_ball}
%files lang -f %{name}.lang
%else

%files lang -f %_sourcedir/%name-%version/%{name}.lang
%endif

%changelog
openSUSE Build Service is sponsored by