File primehack.spec of Package dolphin-primehack

#
# Spec file for package Dolphin Emulator
#
# Copyright © 2014–2020 Markus S. <kamikazow@opensuse.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

%define _localname  dolphin-emu
%define _prettyname PrimeHack-Dolphin
%define _descAddendum This version differs from official Dolphin by being solely for playing Metroid Prime Trilogy (the Wii versions) with keyboard and mouse.

# Use Clang. "g++" works fine but compilation time is about twice as long.
# Might change it back to GCC if reports of horrible performance come in.
%define _cxx clang++

Name:             primehack
Summary:          %{_prettyname}, a GameCube and Wii Emulator
Version:          5.0
Release:          0
License:          GPL-2.0-or-later
URL:              https://github.com/shiiion/dolphin
Source0:          %{name}-%{version}.tar.xz
# https://commons.wikimedia.org/wiki/File:Lightning_Bolt_on_Circle.svg
# Released on January 25, 2006 by _Crotalus horridus_ as Public Domain.
Source1:          dolphin-emu.svg
Source2:          dolphin-emu.appdata.xml
ExclusiveArch:    x86_64 aarch64

# Package names verified with Fedora and openSUSE.
# Should the packages in your distro be named differently,
# see http://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto
#
# All other distros should work as well as Dolphin bundles
# its dependencies for static linking.

BuildRequires:    cmake >= 3.10
BuildRequires:    desktop-file-utils
BuildRequires:    binutils clang gcc gcc-c++
BuildRequires:    fmt-devel
BuildRequires:    hicolor-icon-theme
BuildRequires:    libevdev-devel
BuildRequires:    libSM-devel
BuildRequires:    libcurl-devel
BuildRequires:    lzo-devel
BuildRequires:    mbedtls-devel
BuildRequires:    pugixml-devel
BuildRequires:    sed
BuildRequires:    vulkan-devel
BuildRequires:    pkgconfig(alsa)
BuildRequires:    pkgconfig(ao)
BuildRequires:    pkgconfig(bluez)
BuildRequires:    pkgconfig(gl)
BuildRequires:    pkgconfig(libpng)
BuildRequires:    pkgconfig(libpulse)
BuildRequires:    pkgconfig(libudev)
BuildRequires:    pkgconfig(libusb-1.0)
BuildRequires:    pkgconfig(Qt5Core)
BuildRequires:    pkgconfig(Qt5Widgets)
BuildRequires:    pkgconfig(sdl2)
BuildRequires:    pkgconfig(sfml-all)
BuildRequires:    pkgconfig(soundtouch)
BuildRequires:    pkgconfig(xi)
BuildRequires:    pkgconfig(xext)
BuildRequires:    pkgconfig(xinerama)
BuildRequires:    pkgconfig(xrandr)
BuildRequires:    pkgconfig(xxf86vm)
BuildRequires:    pkgconfig(zlib)

%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
BuildRequires:    gettext
BuildRequires:    gtest-devel
BuildRequires:    hidapi-devel
BuildRequires:    libappstream-glib
BuildRequires:    mesa-libGL-devel
BuildRequires:    miniupnpc-devel
BuildRequires:    ninja-build
%endif

%if 0%{?suse_version}
BuildRequires:    appstream-glib
BuildRequires:    libhidapi-devel
BuildRequires:    libminiupnpc-devel
BuildRequires:    libQt5Gui-private-headers-devel
BuildRequires:    ninja
BuildRequires:    update-desktop-files
BuildRequires:    pkg-config
BuildRequires:    pkgconfig(libavcodec)
BuildRequires:    pkgconfig(libavformat)
BuildRequires:    pkgconfig(libavutil)
BuildRequires:    pkgconfig(libswscale)
%endif

Recommends:       dolphin-emu-udevrules
Conflicts:        dolphin-emu

%description
%{_prettyname} is an emulator for Nintendo GameCube and Wii.
It allows PC gamers to enjoy games for these two consoles in full HD with
several enhancements such as compatibility with all PC controllers, turbo
speed, networked multiplayer, and more.
Most games run perfectly or with minor bugs.

%{_descAddendum}

%package lang
Summary:          Translations for %{_prettyname} Emulator
BuildArch:        noarch

%description lang
Translations into various languages for %{_prettyname} Emulator

%prep
%setup -q -n %{name}-%{version}

%build
##export CCFLAGS='%{optflags}'

# Set default audio back-end.
# Possible options (not all are built by default):
# - ALSA (Linux default)
# - CUBEB (cross-platform, default on Win and macOS)
# - OPENAL (cross-platform)
# - OPENSLES (cross-platform, default on Android)
# - PULSEAUDIO (Linux-only)
# - NULLSOUND (no audio output)
%define _audiobackend CUBEB
sed -i 's/backend = BACKEND_ALSA/backend = BACKEND_%{_audiobackend}/g' ./Source/Core/AudioCommon/AudioCommon.cpp

# CMake options:
# - CMAKE_CXX_COMPILER: Set GCC version
# - ENABLE_ALSA: ALSA sound back-end (on by default)
# - ENABLE_ANALYTICS: Analytics on (turn off for forks)
# - ENABLE_QT: Qt GUI (on by default)
# - DOLPHIN_WC_REVISION: Set vesion number for About window (not set for PrimeHack)
# - DOLPHIN_WC_BRANCH: Set branch name for About window (usually set to "master")
# - USE_DISCORD_PRESENCE: Enables Discord Rich Presence, show the current game on Discord

cmake \
      -DCMAKE_CXX_COMPILER=%{_cxx} \
      -DENABLE_ALSA=ON \
      -DENABLE_QT=ON \
      -DENABLE_ANALYTICS=OFF \
      -DUSE_DISCORD_PRESENCE=ON \
      -DDOLPHIN_WC_DESCRIBE=%{version} \
      -DDOLPHIN_WC_BRANCH=master \
      -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_INSTALL_PREFIX=%{_prefix} \
      -G "Ninja" \
      .

ninja -v

%install
touch Data/dolphin-emu.png

DESTDIR=%{buildroot} ninja install

# Delete static libraries
find %{buildroot} -name '*.a' -delete
# Delete development files
rm -rf %{buildroot}%{_includedir}/

# Install appdata.xml
install -p -D -m 0644 %{S:2} %{buildroot}/%{_datadir}/appdata/%{_localname}.appdata.xml

# Use custom icon
rm -rf %{buildroot}%{_datadir}/icons/hicolor
install -Dm 755 %{S:1} "%{buildroot}/%{_datadir}/icons/hicolor/scalable/apps/%{_localname}.svg"

%find_lang %{_localname}

%check
appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/appdata/*.appdata.xml

%files
%defattr(-,root,root,-)
%doc COPYING Readme.md
%{_bindir}/%{_localname}*
%{_bindir}/dolphin-tool
%{_datadir}/%{_localname}
%{_datadir}/appdata/*.appdata.xml
%{_datadir}/applications/%{_localname}.desktop
%{_datadir}/icons/hicolor/scalable/apps/%{_localname}.svg
%{_mandir}/man6/%{_localname}*

%files lang -f %{_localname}.lang

%changelog
openSUSE Build Service is sponsored by