File d1x-rebirth.spec of Package d1x-rebirth

# norootforbuild

%define _prefix	/usr

Summary:	Port of the 1995 classic game Descent 1: First Strike
Name:		d1x-rebirth
Version:	0.58.1
Release:	1
License:	SUSE-Freeware
Group:		Amusements/Games/Action/Shoot
Url:		http://www.dxx-rebirth.com/
Source:		http://sourceforge.net/projects/dxx-rebirth/files/%{name}_v%{version}-src.tar.gz
Source1:	%{name}.png
Source2:	descent-pc-shareware.zip
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires:	dos2unix
BuildRequires:	gcc-c++
BuildRequires:	Mesa-devel
BuildRequires:	nasm
BuildRequires:	scons
BuildRequires:	SDL-devel
BuildRequires:	SDL_image-devel
BuildRequires:	SDL_mixer-devel
BuildRequires:	physfs-devel
BuildRequires:	unzip
BuildRequires:	update-desktop-files
%if 0%{?suse_version} >= 1500
BuildRequires:  python2
%endif
Requires:	physfs
Requires:	%{name}-exe

%description
DXX-Rebirth is a Source Port of the Descent & Descent ][ Engines and
provides classical Gameplay combined with OpenGL graphics and effects,
a bunch of improvements and new features.

For more information please visit the web site:
http://www.dxx-rebirth.com/

%package sdl
Group:		Amusements/Games/Action/Shoot
Summary:	Descent for Linux, SDL version
Requires:	d1x-rebirth = %{version}
Requires:	SDL
Requires:	SDL_image
Requires:	SDL_mixer
#Conflicts:	d1x-rebirth-gl
Provides:	%{name}-exe

%description sdl
DXX-Rebirth is a Source Port of the Descent & Descent ][ Engines and
provides classical Gameplay combined with OpenGL graphics and effects,
a bunch of improvements and new features.

For more information please visit the web site:
http://www.dxx-rebirth.com/

This version uses SDL for Audio, Input/Output and graphics
rendering.

%package gl
Group:		Amusements/Games/Action/Shoot
Summary:	Descent for Linux, OpenGL version
Requires:	%{name} = %{version}
Requires:	SDL_image
Requires:	SDL_mixer
#Conflicts:	d1x-rebirth-sdl
Provides:	%{name}-exe

%description gl
DXX-Rebirth is a Source Port of the Descent & Descent ][ Engines and
provides classical Gameplay combined with OpenGL graphics and effects,
a bunch of improvements and new features.

For more information please visit the web site:
http://www.dxx-rebirth.com/

This version uses SDL for Audio and Input/Output and OpenGL for
graphics rendering.

%package demo
Group:		Amusements/Games/Action/Shoot
Summary:	Descent for Linux, game data (demo version)
Requires:	%{name} = %{version}

%description demo
DXX-Rebirth is a Source Port of the Descent & Descent ][ Engines and
provides classical Gameplay combined with OpenGL graphics and effects,
a bunch of improvements and new features.

For more information please visit the web site:
http://www.dxx-rebirth.com/

This package contains the game data files from the demo version.

%prep
%setup -q -n %{name}_v%{version}-src -a2
dos2unix     d1x.ini *.txt
%__chmod 644 d1x.ini *.txt
sed -i 's/print \(.*\)/print\(\1\)/' SConstruct
sed -i "s/array = struct.pack.*/array = struct.pack\('cccc', b'\\\\x01', b'\\\\x02', b'\\\\x03', b'\\\\x04'\)/" SConstruct

%build
# currently needed with GCC10
export CFLAGS="-fcommon"
# d1x-gl
%if 0%{?suse_version} >= 1500
python2 %{_bindir}/scons %{?jobs:-j%{jobs}} \
%else
scons %{?jobs:-j%{jobs}} \
%endif
	sharepath=%{_datadir}/games/descent \
	opengl=1 \
	sdlmixer=1 \
	asm=0
mv d1x-rebirth d1x-rebirth-gl

# d1x-sdl
%if 0%{?suse_version} >= 1500
python2 %{_bindir}/scons -c
python2 %{_bindir}/scons %{?jobs:-j%{jobs}} \
%else
scons -c
scons %{?jobs:-j%{jobs}} \
%endif
	sharepath=%{_datadir}/games/descent \
	opengl=0 \
	sdlmixer=1 \
	asm=0
mv d1x-rebirth d1x-rebirth-sdl

%install
# binaries
%__install -dm 755 %{buildroot}%{_bindir}/
%__install -m 755 d1x-rebirth-gl \
	%{buildroot}%{_bindir}/
%__install -m 755 d1x-rebirth-sdl \
	%{buildroot}%{_bindir}/

%__install -dm 755 %{buildroot}%{_datadir}/games/descent
# game data
%__install -m 644 descent.pig %{buildroot}%{_datadir}/games/descent
%__install -m 644 descent.hog %{buildroot}%{_datadir}/games/descent

# icon
%__install -dm 755 %{buildroot}%{_datadir}/pixmaps
%__install -m 644 %{SOURCE1} \
	%{buildroot}%{_datadir}/pixmaps

# menu
%__install -dm 755 %{buildroot}%{_datadir}/applications
%__cat > %{name}-sdl.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=D1x (SDL version)
Comment=Port of the 1995 classic game Descent 1: First Strike
Exec=%{_bindir}/d1x-rebirth-sdl
Icon=%{name}
Categories=Game;ActionGame;
EOF
%__install -m 644 %{name}-sdl.desktop \
	%{buildroot}%{_datadir}/applications
%suse_update_desktop_file %{name}-sdl Game ActionGame

%__cat > %{name}-gl.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=D1x (OpenGL version)
Comment=Port of the 1995 classic game Descent 1: First Strike
Exec=%{_bindir}/d1x-rebirth-gl
Icon=%{name}
Categories=Game;ActionGame;
EOF
%__install -m 644 %{name}-gl.desktop \
	%{buildroot}%{_datadir}/applications
%suse_update_desktop_file %{name}-gl Game ActionGame

%clean
[ -d "%{buildroot}" -a "%{buildroot}" != "" ] && %__rm -rf "%{buildroot}"

%files
%defattr(-,root,root)
%doc *.txt *.ini
%dir %{_datadir}/games/descent
%{_datadir}/pixmaps/%{name}.png

%files sdl
%defattr(-,root,root)
%doc COPYING*
%{_bindir}/d1x-rebirth-sdl
%{_datadir}/applications/%{name}-sdl.desktop

%files gl
%defattr(-,root,root)
%doc COPYING*
%{_bindir}/d1x-rebirth-gl
%{_datadir}/applications/%{name}-gl.desktop

%files demo
%defattr(-,root,root)
%{_datadir}/games/descent/*

%changelog
* Fri May 28 2021 Wolfgang Bauer <wbauer@tmo.at>
- Move executables from /usr/games/ to /usr/bin/
- Require one of the executables to be installed

* Fri Oct 08 2020 Wolfgang Bauer <wbauer@tmo.at>
- Add "-fcommon" to the compiler flags to fix build with GCC10

* Fri Oct 05 2018 Wolfgang Bauer <wbauer@tmo.at>
- Fix build on TW and Leap 15 by explicitly running scons with python2

* Tue Aug 06 2013 Wolfgang Bauer <wbauer@tmo.at> - 0.58.1
- update to 0.58.1

* Tue May 15 2012 Wolfgang Bauer <wbauer@tmo.at> - 0.57.3
- initial package
openSUSE Build Service is sponsored by