File decaf-emu.spec of Package decaf-emu

#
# spec file for package decaf-emu
#
# Copyright (c) 2016 SUSE LINUX 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/
#


Name:           decaf-emu
Version:        20200907
Release:        0
Summary:        Wii U Emulator
License:        GPL-3.0+
Group:          System/Emulators/Other
Url:            https://github.com/decaf-emu/decaf-emu
Source:         %{name}-%{version}.tar.xz
Source1:        FindFFmpeg.cmake
ExclusiveArch:  x86_64

#Factory
BuildRequires:  gcc-c++

BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  pkgconfig(sdl2)
BuildRequires:  pkgconfig(zlib)
BuildRequires:	pkgconfig(glfw3)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(vulkan)
BuildRequires:  pkgconfig(libopenssl)
BuildRequires:  pkgconfig(libuv)
BuildRequires:  pkgconfig(libcares)
BuildRequires:  glslang-devel

#Qt deps:
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5OpenGL)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Xml)
BuildRequires:  pkgconfig(Qt5Widgets)

#FFMPEG deps_
BuildRequires:  pkgconfig(libavcodec)
BuildRequires:  pkgconfig(libswscale)
BuildRequires:  pkgconfig(libavfilter)
BuildRequires:  pkgconfig(libavutil)

#Wayland deps:
BuildRequires:  pkgconfig(wayland-client)
BuildRequires:  pkgconfig(wayland-client++)
BuildRequires:  pkgconfig(wayland-egl) 
BuildRequires:  pkgconfig(wayland-protocols)
BuildRequires:  pkgconfig(wayland-server)

%description
Researching Wii U emulation. Licensed under the terms of the GNU General Public License, version 3 or later (GPLv3+).

%prep
%setup -q
#Adapt FindFFMPEG from ppsspp
mv %{SOURCE1} CMakeModules/FindFFMPEG.cmake

#Fix wayland include dir
sed -i 's/if(DECAF_PLATFORM_WAYLAND)/if(DECAF_PLATFORM_WAYLAND)\ninclude_directories(${WAYLAND_INCLUDE_DIR})/' src/libgpu/CMakeLists.txt

%build
mkdir build
cd build

cmake .. \
        -Wno-dev \
        -DCMAKE_C_FLAGS:STRING="%optflags" \
        -DCMAKE_CXX_FLAGS:STRING="%optflags" \
        -DCMAKE_INSTALL_PREFIX="%{_libexecdir}/%{name}" \
        -DDECAF_FFMPEG=OFF \
        -DOpenGL_GL_PREFERENCE=GLVND

%make_jobs

%install
%cmake_install

# Install wrapper(s)
cat > %{buildroot}%{_libexecdir}/%{name}/decaf-common << 'EOF'
if [ -d ~/.config/decaf ] ; then
	if ! [ -e ~/.config/decaf/resources ] ; then
		ln -sf %{_libexecdir}/%{name}/resources ~/.config/decaf/
	fi
else 
	mkdir -p ~/.config/decaf
	ln -sf %{_libexecdir}/%{name}/resources ~/.config/decaf/
fi

EOF

mkdir -p %{buildroot}%{_bindir}

#/usr/bin/decaf-sdl
cat > %{buildroot}%{_bindir}/decaf-sdl << 'EOF'
#!/bin/sh
. %{_libexecdir}/%{name}/decaf-common
cd ~/.config/decaf
exec %{_libexecdir}/%{name}/decaf-sdl "$@"

EOF

#/usr/bin/decaf-cli
cat > %{buildroot}%{_bindir}/decaf-cli << 'EOF'
#!/bin/sh
. %{_libexecdir}/%{name}/decaf-common
cd ~/.config/decaf
exec %{_libexecdir}/%{name}/decaf-cli "$@"

EOF

%fdupes %{buildroot}

%check
%ctest

%files
%defattr(-,root,root)
%doc README.md
%license LICENSE.md

%attr(755, root, root) %{_bindir}/decaf-sdl
%attr(755, root, root) %{_bindir}/decaf-cli
%{_libexecdir}/%{name}

%changelog

openSUSE Build Service is sponsored by