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:        20181107
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
ExclusiveArch:  x86_64

%if 0%{?is_opensuse}

#LEAP 42.3
%if 0%{?sle_version} == 120300
BuildRequires:	gcc7-c++
%else

#LEAP 42.2
%if 0%{?sle_version} == 120200
BuildRequires:  gcc6-c++
%else

#Factory
BuildRequires:  gcc-c++
%endif
%endif
%endif

BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  pkgconfig(sdl2)
BuildRequires:  pkgconfig(zlib)
BuildRequires:	pkgconfig(glfw3)

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

%prep
%setup -q

%build
mkdir build
cd build

%if 0%{?is_opensuse}

#LEAP 42.3
%if 0%{?sle_version} == 120300
export CC=gcc-7
export CXX=g++-7
%else

#LEAP 42.2
%if 0%{?sle_version} == 120200
export CC=gcc-6
export CXX=g++-6
%endif
%endif
%endif

cmake .. \
        -DCMAKE_C_FLAGS:STRING="%optflags" \
        -DCMAKE_CXX_FLAGS:STRING="%optflags" \
        -DCMAKE_INSTALL_PREFIX="%{_libexecdir}/%{name}"

%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