File snes9x.spec of Package snes9x
#
# spec file for package snes9x
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2018–2021 Markus S. <kamikazow@opensuse.org>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
%define use_clang 1
%define use_lld 1
%ifarch %ix86 %arm
%define use_lto 0
%else
%define use_lto 1
%endif
%define __builder ninja
Name: snes9x
Version: 1.63+11~git20240802.8b1d6739
Release: 0
Summary: Portable, freeware Super Nintendo Entertainment System (TM) emulator
License: SUSE-Freeware AND GPL-2.0-only AND GPL-3.0-only AND LGPL-2.0-only AND LGPL-2.1-only
Group: System/Emulators/Other
URL: https://www.snes9x.com/
Source: %{name}-%{version}.tar.xz
Source1: snes9x-gtk.appdata.xml
#Patch: snes9x_gcc13.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: intltool
BuildRequires: binutils
BuildRequires: cmake
BuildRequires: meson
BuildRequires: nasm
BuildRequires: ninja
BuildRequires: fdupes
BuildRequires: hicolor-icon-theme
%if 0%{?use_clang}
BuildRequires: clang-devel
#BuildRequires: npth-devel
%if 0%{?use_lld}
BuildRequires: lld
%else
BuildRequires: binutils-gold
BuildRequires: llvm-gold
%endif
%else
BuildRequires: binutils-gold
BuildRequires: gcc-c++
%endif
BuildRequires: freeglut-devel
BuildRequires: glslang-devel
BuildRequires: libdrm-devel
BuildRequires: libepoxy-devel
BuildRequires: libpng-devel
BuildRequires: libxml2-devel
BuildRequires: qt6-gui-private-devel
BuildRequires: pkgconfig
BuildRequires: pkgconfig(Qt6Gui)
BuildRequires: pkgconfig(Qt6Widgets)
BuildRequires: pkgconfig(SPIRV-Tools)
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(gtk+-3.0)
BuildRequires: pkgconfig(gtkmm-3.0)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(libyuv)
BuildRequires: pkgconfig(portaudio-2.0)
BuildRequires: pkgconfig(sdl2)
BuildRequires: pkgconfig(xrandr)
BuildRequires: pkgconfig(xv)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(wayland-egl)
BuildRequires: pkgconfig(zlib)
BuildRequires: minizip-ng-devel
BuildRequires: appstream-glib
BuildRequires: update-desktop-files
Requires(post): hicolor-icon-theme
Requires(postun): hicolor-icon-theme
%description
Snes9x is a portable, freeware Super Nintendo Entertainment System
(SNES) emulator. It basically allows you to play most games designed
for the SNES and Super Famicom Nintendo game systems on your PC.
%package -n %{name}-gtk
Summary: Graphical User Interface for snes9x
Group: System/Emulators/Other
Requires: %{name} = %{version}
%description -n %{name}-gtk
This package adds a GTK graphical user interface to snes9x.
%package -n %{name}-qt
Summary: Graphical User Interface for snes9x
Group: System/Emulators/Other
Requires: %{name} = %{version}
%description -n %{name}-qt
This package adds a Qt graphical user interface to snes9x.
%prep
%autosetup -p1
# On openSUSE, joysticks appear under /dev/input:
%if 0%{?suse_version}
perl -pi -e 's,/dev/js,/dev/input/js,g;' unix/unix.cpp
%endif
sed -i -e 's:Snes9x:Snes9x-gtk:' gtk/data/snes9x-gtk.desktop
cp -v gtk/data/snes9x-gtk.desktop gtk/data/snes9x-qt.desktop
sed -i -e 's:gtk:qt:g' gtk/data/snes9x-qt.desktop
%build
# this macro needs 'BuildRequires: memory-constraints'
#limit_build -m 2000
ulimit -Sn 4000
export SUSE_ASNEEDED=0
export SUSE_ZNOW=0
#export UCFLAGS="%{optflags} -fno-omit-frame-pointer"
export UCFLAGS="${UCFLAGS} -w -fPIC -O3"
%ifarch x86_64
export UCFLAGS="${UCFLAGS} -march=x86-64 -mtune=generic -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
%endif
export ULDFLAGS="-fPIC -Wl,--gc-sections -Wl,-O1 -Wl,--icf=safe"
%if 0%{?use_clang}
export CC=clang
export CXX=clang++
export UCFLAGS="${UCFLAGS} -v"
%ifarch x86_64
#export UCFLAGS="${UCFLAGS} -fglobal-isel"
%endif
export UCFLAGS="${UCFLAGS} -fbracket-depth=1024 -fconstexpr-depth=1024 -D_GNU_SOURCE"
export UCXXFLAGS="${UCFLAGS}"
%if 0%{?use_lld}
export ULDFLAGS="${ULDFLAGS} -fuse-ld=lld"
%ifarch %ix86 %arm
export ULDFLAGS="${ULDFLAGS} -Wl,-z,notext"
%endif
export LD="lld"
alias ld=ld.lld
%else
export ULDFLAGS="${ULDFLAGS} -fuse-ld=gold -Wl,--sort-common -Wl,-O1"
export LD=ld.gold
alias ld=gold
%endif
export HOST="$(${CC} -print-target-triple)"
%else
export CC=gcc
export CXX=g++
export UCFLAGS="${UCFLAGS} -ftree-parallelize-loops=4 -ftree-vectorize -fpredictive-commoning"
export UCXXFLAGS="${UCFLAGS}"
export ULDFLAGS="${ULDFLAGS} -fuse-ld=gold -Wl,--sort-common -Wl,-O1"
export LD=ld.gold
alias ld=gold
export HOST="%{_target_platform}"
%endif
%if !0%{?use_lto}
%global _lto_cflags %{nil}
%global _lto_ldlags %{nil}
%else
%if 0%{?use_clang}
%if 0%{?use_lld}
%global _lto_cflags -flto=thin
%global _lto_ldlags -flto=thin -Wl,--plugin-opt=O3 %{?jobs:-Wl,--threads=%{jobs}}
%else
%global _lto_cflags -flto=thin
%global _lto_ldlags -flto=thin
%endif
%else
%global _lto_cflags -fuse-linker-plugin %{_lto_cflags} -ffat-lto-objects -flto-odr-type-merging
%global _lto_ldlags -fuse-linker-plugin -flto=%{?jobs:%{jobs}}
%endif
%endif
export TARGET="${HOST}"
export UCFLAGS="${UCFLAGS} %{_lto_cflags}"
export UCXXFLAGS="${UCXXFLAGS} %{_lto_cflags}"
export ULDFLAGS="${ULDFLAGS} %{_lto_cflags} %{_lto_ldlags}"
# override OBS defaults ?
export CFLAGS="${UCFLAGS}"
export CXXFLAGS="${UCXXFLAGS}"
export LDFLAGS="${ULDFLAGS}"
export TOPDIR="${PWD}"
pushd unix
%configure --enable-netplay \
%ifarch x86_64
--enable-sse41 \
%endif
CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"
%make_build
popd
%define customopts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="%{_prefix}" -DCMAKE_INSTALL_LIBEXEC="%_libexecdir" -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_LINKER="${LD}" -DCMAKE_C_FLAGS="${CFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" -DCMAKE_MODULE_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" -DCMAKE_STATIC_LINKER_FLAGS="" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DTHREADS_PREFER_PTHREAD_FLAG=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DOpenGL_GL_PREFERENCE=GLVND
%define __sourcedir gtk
%define __builddir build_gtk
%cmake %{customopts}
%cmake_build
cd "${TOPDIR}"
%define __sourcedir qt
%define __builddir build_qt
%cmake %{customopts}
%cmake_build
%install
# Install CLI version
mkdir -p %{buildroot}%{_bindir}
install -m 755 unix/snes9x %{buildroot}%{_bindir}
# Install AppData file
install -d %{buildroot}%{_datadir}/metainfo
install -p -m 644 %{SOURCE1} %{buildroot}%{_datadir}/metainfo
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/*.appdata.xml
%define __builddir build_gtk
%cmake_install
%define __builddir build_qt
%cmake_install
install -p -m 644 gtk/data/snes9x-qt.desktop %{buildroot}%{_datadir}/applications/%{name}-qt.desktop
# fix stupidity
mv -vf %{buildroot}%{_prefix}/locale %{buildroot}%{_datadir}/ || echo "no stupidity detected"
%find_lang snes9x-gtk
%files
%doc docs/*
%doc unix/docs/readme_unix.html
%license LICENSE
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_datadir}/icons/hicolor/*/apps/snes9x.*
%files gtk -f %{name}-gtk.lang
%license LICENSE
%doc gtk/AUTHORS
%{_bindir}/%{name}-gtk
%{_datadir}/metainfo/%{name}-gtk.appdata.xml
%{_datadir}/applications/%{name}-gtk.desktop
%files qt
%license LICENSE
%{_bindir}/%{name}-qt
%{_datadir}/applications/%{name}-qt.desktop
%changelog