File devilutionx.spec of Package devilutionx

#
# spec file for package devilutionx
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2019-2021, Martin Hauke <mardnh@gmx.de>
#
# 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/
#


# See 3rdParty/simpleini/CMakeLists.txt
%define zerotier_hash  a34ba7f
%define mpq_hash 0f10bd1600f406b13932bf5351ba713361262184
%define simpleini_hash 9b3ed7ec815997bc8c5b9edf140d6bde653e1458
%define smackerdec_hash 2997ee0e41e91bb723003bc09234be553b190e38
Name:           devilutionx
Version:        1.4.0
Release:        0
Summary:        An open source implementation of the Diablo 1 game engine
# 3rdParty/libsmacker/* is licensed under CC-BY-NC-2.0 and CC-BY-SA-NC-2.0
# 3rdParty/[Storm|StormLib]/* is licensed under MIT
# 3rdParty/Radon/* is licensed under MIT
# libzt is licensed under the BUSL-1.1
# simpleini is licensed under the MIT license
License:        BUSL-1.1 AND SUSE-Public-Domain AND MIT
Group:          Amusements/Games/RPG
URL:            https://github.com/diasurgical/devilutionX
#Git-Clone:     https://github.com/diasurgical/devilutionX.git
Source0:        https://github.com/diasurgical/devilutionX/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        https://github.com/brofield/simpleini/archive/%{simpleini_hash}.tar.gz#/simpleini-%{simpleini_hash}.tar.gz
Source2:        https://github.com/diasurgical/libsmackerdec/archive/%{smackerdec_hash}.tar.gz#/libsmackerdec-%{smackerdec_hash}.tar.gz
Source3:        https://github.com/diasurgical/libmpq/archive/%{mpq_hash}.tar.gz#/libmpq-%{mpq_hash}.tar.gz
Source4:        libzt-%{zerotier_hash}.tar
Source98:       devilutionx-rpmlintrc
Source99:       baselibs.conf
# PATCH-FIX-OPENSUSE accept-libzt-tarball.patch -- Allow tarball instead of full git clone for zerotier
Patch0:         accept-libzt-tarball.patch
# PATCH-FIX-OPENSUSE use-system-libraries.patch -- Use system asio, SDL_audiolib, SDL2_image, libpng, sodium, and fmt
Patch1:         use-system-libraries.patch
# PATCH-FIX-UPSTREAM aarch64-fix-detection.patch -- Fix arch detection to fix aarch64 build
Patch2:         https://github.com/zerotier/libzt/pull/179.patch#/aarch64-fix-detection.patch
BuildRequires:  asio-devel
BuildRequires:  cmake >= 3.13
BuildRequires:  gcc-c++
BuildRequires:  gmock
BuildRequires:  gtest
BuildRequires:  hicolor-icon-theme
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  (cmake(fmt) >= 7 and cmake(fmt) < 8)
BuildRequires:  pkgconfig(SDL2_image)
BuildRequires:  pkgconfig(SDL_audiolib)
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libsodium)
BuildRequires:  pkgconfig(sdl2)
# CharisSILB.ttf:
Requires:       sil-charis-fonts

%description
DevilutionX is a open source implementation of the game engine used
in Diablo1.
This package only includes the binary files, you still need the data
files from the original Diablo1 CD.

%prep
%setup -q -n devilutionX-%{version}
%patch0 -p1
%patch1 -p1
mkdir prefetched
pushd prefetched
for s in %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4}; do tar -xf "$s"; done
pushd libzt-%{zerotier_hash}
%patch2 -p1
popd
popd

%build
export CXXFLAGS='%{optflags} -DTTF_FONT_PATH=\"%{_datadir}/fonts/truetype/CharisSILB.ttf\"'
%cmake \
  -DVERSION_NUM=%{version} \
  -DBINARY_RELEASE=ON \
  -DPIE=ON \
  -DDEVILUTIONX_SYSTEM_ASIO=ON \
  -DDEVILUTIONX_SYSTEM_SDL_AUDIOLIB=ON \
  -DDEVILUTIONX_SYSTEM_SDL_IMAGE=ON \
  -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON \
  -DFETCHCONTENT_SOURCE_DIR_LIBMPQ=../prefetched/libmpq-%{mpq_hash} \
  -DFETCHCONTENT_SOURCE_DIR_SIMPLEINI=../prefetched/simpleini-%{simpleini_hash} \
  -DFETCHCONTENT_SOURCE_DIR_LIBZT=../prefetched/libzt-%{zerotier_hash} \
  -DFETCHCONTENT_SOURCE_DIR_LIBSMACKERDEC=../prefetched/libsmackerdec-%{smackerdec_hash}
%cmake_build

%install
install -D -m 0755 build/devilutionx %{buildroot}%{_bindir}/devilutionx
install -p -D -m644 Packaging/resources/icon.png %{buildroot}%{_datadir}/icons/hicolor/512x512/apps/%{name}.png
%suse_update_desktop_file -c %{name} "DevilutionX" "A Diablo1 Game Engine" %{name} %{name} Game RolePlaying

%post
echo "copy diabdat.mpq to ~/.local/share/diasurgical/devilution/"

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop

%changelog
openSUSE Build Service is sponsored by