File hexen2.spec of Package hexen2

#
# spec file for package hexen2
#
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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/
#

%define gamecode_ver 1.29a

Name:           hexen2
Version:        1.5.8
Release:        0
Summary:        Hexen II: Hammer of Thyrion
License:        GPL-2.0+
Group:          Amusements/Games/3D/Shoot
URL:            http://uhexen2.sourceforge.net/
Source:         http://download.sourceforge.net/uhexen2/hexen2source-%{version}.tgz
Source1:        http://download.sourceforge.net/uhexen2/hexen2source-gamecode-%{version}.tgz
Source2:        http://download.sourceforge.net/uhexen2/hexenworld-pakfiles-0.15.tgz
Source3:        hexen2.desktop
Source4:        hexen2-portals.desktop
Source5:        hexenworld.desktop
Source6:        README.openSUSE
# PATCH-FIX-OPENSUSE hexen2-location-runscript.diff
Patch:          hexen2-location-runscript.diff
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(flac)
BuildRequires:  pkgconfig(ogg)
BuildRequires:  pkgconfig(sdl) >= 1.2.4
BuildRequires:  pkgconfig(vorbis)
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Hexen II is a class based shooter game by Raven Software from 1997.
Hammer of Thyrion is a port of the GPL'ed Hexen II source code.
This package contains binaries that will run both the original game
and the Portal of Praevus mission pack, and a dedicated server.

You still need the data files from the original Hexen II CD or
the demo.

%package -n hexenworld
Group:          Amusements/Games/3D/Shoot
Summary:        Hexen II Client and Server
Requires:       %{name} >= %{version}

%description -n hexenworld
This is an extension of Hexen II with internet play enhancements.
Hammer of Thyrion is a port of the GPL'ed Hexen II source code.
This package contains the files which are required to run a HexenWorld
server or client, and a master server application.

%prep
%setup -q -n hexen2source-%{version} -a1 -a2
%patch
cp %{SOURCE3} .
cp %{SOURCE4} .
cp %{SOURCE5} .
cp %{SOURCE6} .

# fix for file-contains-date-and-time warning
set_date=`date --date "@\`stat --format %Y %{_sourcedir}/%{name}.changes\`" +"%B %Y"`
set_time=`date --date "@\`stat --format %Y %{_sourcedir}/%{name}.changes\`" +"%H:%M"`
find . -name '*.[ch]' -print0 | xargs -0 sed -i -e "s/\_\_DATE\_\_/\"$set_date\"/g;s/\_\_TIME\_\_/\"$set_time\"/g" 

%build
%define engine_buildopt USE_ALSA=yes USE_CODEC_FLAC=yes USE_CODEC_VORBIS=yes USE_CODEC_OPUS=NO USE_CODEC_MP3=no USE_CODEC_MIKMOD=no USE_CODEC_UMX=no USE_CODEC_TIMIDITY=no USE_X86_ASM=no
# Build the main game binaries
make %{?_smp_mflags} -C engine/hexen2 %{engine_buildopt} h2
# use localclean instead of clean to avoid building timidity every time
make -s -C engine/hexen2 localclean
make %{?_smp_mflags} -C engine/hexen2 %{engine_buildopt} glh2
make -s -C engine/hexen2 localclean
# Build the dedicated server
make %{?_smp_mflags} -C engine/hexen2/server
# HexenWorld binaries
make %{?_smp_mflags} -C engine/hexenworld/server
make %{?_smp_mflags} -C engine/hexenworld/client %{engine_buildopt} hw
make -s -C engine/hexenworld/client localclean
make %{?_smp_mflags} -C engine/hexenworld/client %{engine_buildopt} glhw
# HexenWorld master server
make %{?_smp_mflags} -C hw_utils/hwmaster

# Build h2patch
make %{?_smp_mflags} -C h2patch

# Build the hcode compiler
make %{?_smp_mflags} -C utils/hcc
# Build the game-code
utils/hcc/hcc -src gamecode-%{gamecode_ver}/hc/h2 -os
utils/hcc/hcc -src gamecode-%{gamecode_ver}/hc/h2 -os -name progs2.src
utils/hcc/hcc -src gamecode-%{gamecode_ver}/hc/portals -os -oi -on
utils/hcc/hcc -src gamecode-%{gamecode_ver}/hc/hw -os -oi -on
# Done building

%install
mkdir -p %{buildroot}%{_prefix}/lib/%{name}/
install -D -m755 engine/hexen2/glhexen2 %{buildroot}%{_prefix}/lib/%{name}/glhexen2
install -D -m755 engine/hexen2/hexen2 %{buildroot}%{_prefix}/lib/%{name}/hexen2
install -D -m755 engine/hexen2/server/h2ded %{buildroot}%{_prefix}/lib/%{name}/h2ded
install -D -m755 engine/hexenworld/client/hwcl %{buildroot}%{_prefix}/lib/%{name}/hwcl
install -D -m755 engine/hexenworld/client/glhwcl %{buildroot}%{_prefix}/lib/%{name}/glhwcl
install -D -m755 engine/hexenworld/server/hwsv %{buildroot}%{_prefix}/lib/%{name}/hwsv
install -D -m755 hw_utils/hwmaster/hwmaster %{buildroot}%{_prefix}/lib/%{name}/hwmaster
install -D -m755 h2patch/h2patch %{buildroot}%{_prefix}/lib/%{name}/h2patch

# Install the run script and make symlinks to it
install -D -m755 scripts/hexen2-run.sh %{buildroot}/%{_bindir}/hexen2-run.sh
ln -s hexen2-run.sh %{buildroot}/%{_bindir}/glhexen2
ln -s hexen2-run.sh %{buildroot}/%{_bindir}/hexen2
ln -s hexen2-run.sh %{buildroot}/%{_bindir}/h2ded
ln -s hexen2-run.sh %{buildroot}/%{_bindir}/glhwcl
ln -s hexen2-run.sh %{buildroot}/%{_bindir}/hwcl
ln -s hexen2-run.sh %{buildroot}/%{_bindir}/hwsv

# Install the cd-rip scripts
install -D -m755 scripts/cdrip_hexen2.sh %{buildroot}%{_prefix}/lib/%{name}/cdrip_hexen2.sh
install -D -m755 scripts/cdrip_hexen2_xplosiv.sh %{buildroot}%{_prefix}/lib/%{name}/cdrip_hexen2_xplosiv.sh
install -D -m755 scripts/cdrip_hexen2_matroxm3d.sh %{buildroot}%{_prefix}/lib/%{name}/cdrip_hexen2_matroxm3d.sh
install -D -m755 scripts/cdrip_missionpack.sh %{buildroot}%{_prefix}/lib/%{name}/cdrip_missionpack.sh

# Install the gamedata
mkdir -p %{buildroot}%{_prefix}/lib/%{name}/data1/
install -Dm 0644 gamecode-%{gamecode_ver}/hc/h2/progs.dat %{buildroot}%{_prefix}/lib/%{name}/data1/progs.dat
install -Dm 0644 gamecode-%{gamecode_ver}/hc/h2/progs2.dat %{buildroot}%{_prefix}/lib/%{name}/data1/progs2.dat
install -Dm 0644 gamecode-%{gamecode_ver}/res/h2/hexen.rc %{buildroot}%{_prefix}/lib/%{name}/data1/hexen.rc
install -Dm 0644 gamecode-%{gamecode_ver}/res/h2/strings.txt %{buildroot}%{_prefix}/lib/%{name}/data1/strings.txt
install -Dm 0644 gamecode-%{gamecode_ver}/res/h2/default.cfg %{buildroot}%{_prefix}/lib/%{name}/data1/default.cfg

mkdir -p %{buildroot}%{_prefix}/lib/%{name}/portals/
install -Dm 0644 gamecode-%{gamecode_ver}/hc/portals/progs.dat %{buildroot}%{_prefix}/lib/%{name}/portals/progs.dat
install -Dm 0644 gamecode-%{gamecode_ver}/res/portals/hexen.rc %{buildroot}%{_prefix}/lib/%{name}/portals/hexen.rc
install -Dm 0644 gamecode-%{gamecode_ver}/res/portals/strings.txt %{buildroot}%{_prefix}/lib/%{name}/portals/strings.txt
install -Dm 0644 gamecode-%{gamecode_ver}/res/portals/infolist.txt %{buildroot}%{_prefix}/lib/%{name}/portals/infolist.txt
install -Dm 0644 gamecode-%{gamecode_ver}/res/portals/maplist.txt %{buildroot}%{_prefix}/lib/%{name}/portals/maplist.txt
install -Dm 0644 gamecode-%{gamecode_ver}/res/portals/puzzles.txt %{buildroot}%{_prefix}/lib/%{name}/portals/puzzles.txt
install -Dm 0644 gamecode-%{gamecode_ver}/res/portals/default.cfg %{buildroot}%{_prefix}/lib/%{name}/portals/default.cfg

mkdir -p %{buildroot}%{_prefix}/lib/%{name}/hw/
install -Dm 0644 gamecode-%{gamecode_ver}/hc/hw/hwprogs.dat %{buildroot}%{_prefix}/lib/%{name}/hw/hwprogs.dat
install -Dm 0644 gamecode-%{gamecode_ver}/res/hw/mapcycle.cfg %{buildroot}%{_prefix}/lib/%{name}/hw/mapcycle.cfg
install -Dm 0644 gamecode-%{gamecode_ver}/res/hw/server.cfg %{buildroot}%{_prefix}/lib/%{name}/hw/server.cfg
install -Dm 0644 gamecode-%{gamecode_ver}/res/hw/strings.txt %{buildroot}%{_prefix}/lib/%{name}/hw/strings.txt
install -Dm 0644 gamecode-%{gamecode_ver}/res/hw/default.cfg %{buildroot}%{_prefix}/lib/%{name}/hw/default.cfg
install -Dm 0644 hw/pak4.pak %{buildroot}%{_prefix}/lib/%{name}/hw/pak4.pak

# Install ent fixes handling map quirks
mkdir -p %{buildroot}%{_prefix}/lib/%{name}/data1/maps/
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/README.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/README.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/cath.ent %{buildroot}%{_prefix}/lib/%{name}/data1/maps/cath.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/cath.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/cath.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/demo2.ent %{buildroot}%{_prefix}/lib/%{name}/data1/maps/demo2.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/demo2.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/demo2.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/egypt4.ent %{buildroot}%{_prefix}/lib/%{name}/data1/maps/egypt4.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/egypt4.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/egypt4.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/egypt5.ent %{buildroot}%{_prefix}/lib/%{name}/data1/maps/egypt5.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/egypt5.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/egypt5.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/romeric5.ent %{buildroot}%{_prefix}/lib/%{name}/data1/maps/romeric5.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/romeric5.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/romeric5.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/tower.ent %{buildroot}%{_prefix}/lib/%{name}/data1/maps/tower.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/data1/maps/tower.txt %{buildroot}%{_prefix}/lib/%{name}/data1/maps/tower.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/portals/maps/README.txt %{buildroot}%{_prefix}/lib/%{name}/portals/maps/README.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/portals/maps/tibet2.ent %{buildroot}%{_prefix}/lib/%{name}/portals/maps/tibet2.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/portals/maps/tibet2.txt %{buildroot}%{_prefix}/lib/%{name}/portals/maps/tibet2.txt
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/portals/maps/tibet9.ent %{buildroot}%{_prefix}/lib/%{name}/portals/maps/tibet9.ent
install -Dm 0644 gamecode-%{gamecode_ver}/mapfixes/portals/maps/tibet9.txt %{buildroot}%{_prefix}/lib/%{name}/portals/maps/tibet9.txt

# Install the pak deltas
mkdir -p %{buildroot}%{_prefix}/lib/%{name}/patchdat/
mkdir -p %{buildroot}%{_prefix}/lib/%{name}/patchdat/data1
install -Dm 0644 gamecode-%{gamecode_ver}/patch111/patchdat/data1/data1pk0.xd3 %{buildroot}%{_prefix}/lib/%{name}/patchdat/data1/data1pk0.xd3
install -Dm 0644 gamecode-%{gamecode_ver}/patch111/patchdat/data1/data1pk1.xd3 %{buildroot}%{_prefix}/lib/%{name}/patchdat/data1/data1pk1.xd3
install -Dm 0644 gamecode-%{gamecode_ver}/patch111/patchdat.txt %{buildroot}%{_prefix}/lib/%{name}/patchdat.txt

# Install desktop files and icon
install -Dm 0644 %{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop
install -Dm 0644 %{name}-portals.desktop %{buildroot}%{_datadir}/applications/%{name}-portals.desktop
install -Dm 0644 hexenworld.desktop %{buildroot}%{_datadir}/applications/hexenworld.desktop
install -Dm 0644 engine/resource/%{name}.png %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
install -Dm 0644 engine/resource/hexenworld.png %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/hexenworld.png

%files
%defattr(-,root,root)
%{_bindir}/hexen2-run.sh
%{_bindir}/glhexen2
%{_bindir}/hexen2
%{_bindir}/h2ded
%{_datadir}/applications/%{name}.desktop
%{_datadir}/applications/%{name}-portals.desktop
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/32x32
%dir %{_datadir}/icons/hicolor/32x32/apps
%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
%dir %{_prefix}/lib/%{name}
%{_prefix}/lib/%{name}/hexen2
%{_prefix}/lib/%{name}/glhexen2
%{_prefix}/lib/%{name}/h2ded
%{_prefix}/lib/%{name}/h2patch
%dir %{_prefix}/lib/%{name}/patchdat
%dir %{_prefix}/lib/%{name}/patchdat/data1
%{_prefix}/lib/%{name}/patchdat/data1/data1pk0.xd3
%{_prefix}/lib/%{name}/patchdat/data1/data1pk1.xd3
%{_prefix}/lib/%{name}/patchdat.txt
%dir %{_prefix}/lib/%{name}/data1
%{_prefix}/lib/%{name}/data1/progs.dat
%{_prefix}/lib/%{name}/data1/progs2.dat
%{_prefix}/lib/%{name}/data1/hexen.rc
%{_prefix}/lib/%{name}/data1/strings.txt
%{_prefix}/lib/%{name}/data1/default.cfg
%dir %{_prefix}/lib/%{name}/data1/maps
%{_prefix}/lib/%{name}/data1/maps/README.txt
%{_prefix}/lib/%{name}/data1/maps/cath.ent
%{_prefix}/lib/%{name}/data1/maps/cath.txt
%{_prefix}/lib/%{name}/data1/maps/demo2.ent
%{_prefix}/lib/%{name}/data1/maps/demo2.txt
%{_prefix}/lib/%{name}/data1/maps/egypt4.ent
%{_prefix}/lib/%{name}/data1/maps/egypt4.txt
%{_prefix}/lib/%{name}/data1/maps/egypt5.ent
%{_prefix}/lib/%{name}/data1/maps/egypt5.txt
%{_prefix}/lib/%{name}/data1/maps/romeric5.ent
%{_prefix}/lib/%{name}/data1/maps/romeric5.txt
%{_prefix}/lib/%{name}/data1/maps/tower.ent
%{_prefix}/lib/%{name}/data1/maps/tower.txt
%dir %{_prefix}/lib/%{name}/portals
%{_prefix}/lib/%{name}/portals/progs.dat
%{_prefix}/lib/%{name}/portals/hexen.rc
%{_prefix}/lib/%{name}/portals/strings.txt
%{_prefix}/lib/%{name}/portals/puzzles.txt
%{_prefix}/lib/%{name}/portals/infolist.txt
%{_prefix}/lib/%{name}/portals/maplist.txt
%{_prefix}/lib/%{name}/portals/default.cfg
%dir %{_prefix}/lib/%{name}/portals/maps
%{_prefix}/lib/%{name}/portals/maps/README.txt
%{_prefix}/lib/%{name}/portals/maps/tibet2.ent
%{_prefix}/lib/%{name}/portals/maps/tibet2.txt
%{_prefix}/lib/%{name}/portals/maps/tibet9.ent
%{_prefix}/lib/%{name}/portals/maps/tibet9.txt
%{_prefix}/lib/%{name}/cdrip_hexen2.sh
%{_prefix}/lib/%{name}/cdrip_hexen2_xplosiv.sh
%{_prefix}/lib/%{name}/cdrip_hexen2_matroxm3d.sh
%{_prefix}/lib/%{name}/cdrip_missionpack.sh
%doc docs/README
%doc docs/COPYING
%doc docs/BUGS
%doc docs/ABOUT
%doc docs/AUTHORS
%doc docs/Features
%doc docs/CHANGES
%doc docs/CHANGES.old
%doc docs/README.music
%doc docs/README.3dfx
%doc docs/TODO
%doc docs/SrcNotes.txt
%doc docs/ReleaseNotes
%doc docs/ReleaseNotes.old
%doc README.openSUSE

%files -n hexenworld
%defattr(-,root,root)
%{_bindir}/glhwcl
%{_bindir}/hwcl
%{_bindir}/hwsv
%{_datadir}/applications/hexenworld.desktop
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/32x32
%dir %{_datadir}/icons/hicolor/32x32/apps
%{_datadir}/icons/hicolor/32x32/apps/hexenworld.png
%dir %{_prefix}/lib/%{name}
%{_prefix}/lib/%{name}/hwsv
%{_prefix}/lib/%{name}/hwmaster
%{_prefix}/lib/%{name}/hwcl
%{_prefix}/lib/%{name}/glhwcl
%dir %{_prefix}/lib/%{name}/hw
%{_prefix}/lib/%{name}/hw/hwprogs.dat
%{_prefix}/lib/%{name}/hw/mapcycle.cfg
%{_prefix}/lib/%{name}/hw/server.cfg
%{_prefix}/lib/%{name}/hw/pak4.pak
%{_prefix}/lib/%{name}/hw/strings.txt
%{_prefix}/lib/%{name}/hw/default.cfg
%doc docs/README.hwcl
%doc docs/README.hwsv
%doc docs/README.hwmaster

%changelog
openSUSE Build Service is sponsored by