File pcsx2-git.spec of Package pcsx2-git
#
# spec file for package pcsx2-git
#
# Copyright (c) 2015 SUSE LINUX Products 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/
#
%define use_clang 1
%define use_lld 1
# viable only on x86_64… when clang doesn't mess it up and produce segfaulting binaries… or is it ?
%ifarch %ix86 %arm
%define use_clang 1
%define use_lto 0
%else
# Qt/PIC clang LTO bug may prevent that for now. also there is some linking bug with libpcap
%define use_lto 1
%endif
# it's not PCSX2 without absolute ass-backwards anti-user idiocy by design
# the eternal competition in the worst-maintained F/OSS on the planet between it, Khronos and web standards
# see https://github.com/PCSX2/pcsx2/issues/6939 and https://github.com/PCSX2/pcsx2/issues/6115
# and https://github.com/PCSX2/pcsx2/issues/6917 & https://github.com/PCSX2/pcsx2/commit/05bed05afeac6e5d5412886feac5f2e2984135e5
# see https://aur.archlinux.org/packages/pcsx2-git for some snots and crutches
%define qt_ui 1
# revision c07c942659ccf758d118bfcdff5df076c3e4c36c / 1.7.2759+2~git20220522.c07c94265 is the last known to work
%define gtk3_ui 1
%define opencl 0
%define dumbname PCSX2
%define dumbername Pcsx2
%define realname pcsx2
Name: pcsx2-git
License: GPL-3.0
Version: 2.1.45+0~git20240730.e045d4a0f
Release: 0
URL: http://pcsx2.net/
Summary: Sony PlayStation 2 Emulator
Group: System/Emulators/Other
Source: %{realname}-%{version}.tar.xz
Patch0: pcsx2-find_appropriate_shaderc.patch
# crutches for shaderc_moronic backported from duckstation, so we would not need 2 different versions of it
Patch1: pcsx2-shaderc-compatibility.patch
%if 0%{?use_clang}
BuildRequires: clang-devel
#BuildRequires: npth-devel
%if 0%{?use_lld}
BuildRequires: lld
%else
BuildRequires: llvm-gold
BuildRequires: binutils-gold
%endif
%else
BuildRequires: gcc-c++
BuildRequires: binutils-gold
%endif
#BuildRequires: ninja
BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: cmake(ryml)
BuildRequires: extra-cmake-modules
#BuildRequires: glibc-devel
BuildRequires: fdupes
BuildRequires: libaio-devel
BuildRequires: imgui-devel
# non-free library
#BuildRequires: libCg-devel
BuildRequires: libbacktrace-devel
BuildRequires: libjpeg-devel
BuildRequires: openSUSE-release
%if 0%{?opencl}
BuildRequires: opencl-headers
BuildRequires: opencl-cpp-headers
BuildRequires: pkgconfig(OpenCL)
%endif
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(gl)
BuildRequires: pkgconfig(egl)
BuildRequires: pkgconfig(fmt)
BuildRequires: pkgconfig(glew)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(liblz4)
BuildRequires: pkgconfig(liblzma)
BuildRequires: pkgconfig(libpcap)
BuildRequires: pkgconfig(libsparsehash)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(libwebp)
BuildRequires: pkgconfig(libudev)
#BuildRequires: pkgconfig(sdl)
BuildRequires: pkgconfig(sdl2)
BuildRequires: pkgconfig(xcb-proto)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(wayland-protocols)
BuildRequires: pkgconfig(wayland-scanner)
BuildRequires: pkgconfig(samplerate)
BuildRequires: pkgconfig(soundtouch)
BuildRequires: png++-devel
BuildRequires: portaudio-devel
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(jack)
#BuildRequires: pkgconfig(openal)
# https://github.com/PCSX2/pcsx2/pull/3686
BuildRequires: pkgconfig(yaml-cpp)
BuildRequires: pkgconfig(libzip)
BuildRequires: pkgconfig(libzstd)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(harfbuzz)
BuildRequires: pkgconfig(shaderc-moronic)
#BuildRequires: pkgconfig(shaderc)
BuildRequires: pkgconfig(vulkan)
BuildRequires: pkgconfig(SPIRV-Tools)
BuildRequires: glslang-devel
BuildRequires: libzip-tools
BuildRequires: libzstd-devel-static
# ffmpeg
BuildRequires: pkgconfig(libavcodec)
BuildRequires: pkgconfig(libavformat)
BuildRequires: pkgconfig(libavutil)
BuildRequires: pkgconfig(libswresample)
BuildRequires: pkgconfig(libswscale)
%if 0%{?qt_ui}
#BuildRequires: wxQt-devel
#BuildRequires: wxWidgets-any-devel >= 3.0
BuildRequires: qt6-gui-private-devel
BuildRequires: pkgconfig(Qt6Core)
BuildRequires: pkgconfig(Qt6Concurrent)
BuildRequires: pkgconfig(Qt6Gui)
BuildRequires: pkgconfig(Qt6OpenGL)
BuildRequires: pkgconfig(Qt6Multimedia)
BuildRequires: pkgconfig(Qt6Linguist)
BuildRequires: pkgconfig(Qt6Network)
BuildRequires: pkgconfig(Qt6Widgets)
%else
%if 0%{?gtk3_ui}
BuildRequires: wxGTK3-devel
BuildRequires: wxWidgets-any-devel >= 3.0
BuildRequires: pkgconfig(gtk+-3.0)
%else
BuildRequires: wxWidgets-3_0-devel
BuildRequires: pkgconfig(gtk+-2.0)
%endif
%endif
# mix of SDL 1 and 2 libraries can crash wxWidgets
#Conflicts: plugin-sound_sdlu-3_0
Conflicts: %{realname}
Recommends: %{realname}-lang = %{version}
%ifnarch x86_64
Obsoletes: %{realname}-32bit
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Sony PlayStation 2 emulator. Requires a BIOS image in ~/.config/%{dumbname}/bios (will be created when you first run
PCSX2) or in a directory of your choosing. Check http://www.pcsx2.net/guide.php#Bios for details on which files
you need and how to obtain them.
It is developed by one of the top prima donna madmen in all of FOSS who are onsessed with
performing the most inexplicably insane design choices that a sound mind could not ever comprehend.
%{lang_package}
%prep
%autosetup -p1 -n %{realname}-%{version}
# we should use OBS's glslang… BUT it's hardcoded for a particular version of glslang which has terrible versioning, as expected from Khronos
#sed -i -e '/#include/s:StandAlone/:glslang/Public/:g' \
# -e '/#include/s:SPIRV/:glslang/SPIRV/:g' \
# pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp
# DO NOT EVER force march=native that randomly creates binaries with unexpected instructions !
%ifarch x86_64
sed -i -e 's:-march=native:-march=x86-64-v2:g' cmake/BuildParameters.cmake
sed -i -e 's:-msse -msse2:-mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul:g' cmake/BuildParameters.cmake
%else
sed -i -e 's:-march=native:-march=x86-64:g' cmake/BuildParameters.cmake
sed -i -e 's:-mfpmath=sse::g' cmake/BuildParameters.cmake
%endif
# oh, don't be prissy, built with GTK3 and SDL2
sed -i -e "s:FATAL_ERROR:WARNING:g" \
cmake/BuildParameters.cmake
# this useless check likes to shit itself
sed -i '/check_function_exists/d' cmake/FindPCAP.cmake
#for file in $(grep -iRl '#include "PrecompiledHeader.h"' pcsx2); do
# sed -i -e 's:#include "PrecompiledHeader.h"::g' "${file}"
#done
# does it still craps out on wayland ?
#sed -i -e 's:Exec=.*:Exec=env GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb MESA_NO_ERROR=1 %{realname}:' .github/workflows/scripts/linux/pcsx2-qt.desktop
# more and more those dumb bastards hardcode their bundled crap for Windoze's crutches and props
# supposedly, this should be worked around by '-DUSE_SYSTEM_LIBS=ON -DUSE_SYSTEM_RYML=OFF'
#sed -i \
# -e 's:add_subdirectory(3rdparty/fmt/fmt EXCLUDE_FROM_ALL):find_package(fmt REQUIRED):' \
# -e 's:add_subdirectory(3rdparty/rapidyaml/rapidyaml EXCLUDE_FROM_ALL):find_package(ryml REQUIRED):' \
# -e 's:add_subdirectory(3rdparty/lzma EXCLUDE_FROM_ALL):find_package(LibLZMA REQUIRED):' \
# -e 's:add_subdirectory(3rdparty/zstd EXCLUDE_FROM_ALL):find_package(zstd REQUIRED):' \
# -e 's:add_subdirectory(3rdparty/libzip EXCLUDE_FROM_ALL):find_package(libzip REQUIRED):' \
# cmake/SearchForStuff.cmake
#sed -i -e 's/Zstd::Zstd/zstd/g' pcsx2/CMakeLists.txt
#sed -i -e 's/LZMA::LZMA/LibLZMA::LibLZMA/g' 3rdparty/libchdr/CMakeLists.txt
# have no idea why all this stupid crap fails as is
#sed -i \
# -e 's:add_subdirectory(deps/lzma-[1-9\.]* EXCLUDE_FROM_ALL):find_package(LibLZMA REQUIRED):g' \
# -e 's/CHDR_LIBS lzma/CHDR_LIBS LIBLZMA_LIBRARIES/g' \
# -e 's/CHDR_INCLUDES lzma/CHDR_INCLUDES LIBLZMA_INCLUDE_DIRS/g' \
# 3rdparty/libchdr/libchdr/CMakeLists.txt
#sed -i -e 's:CHDR_INCLUDES lzma:CHDR_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/deps/deps/lzma-22.01" "${CMAKE_CURRENT_BINARY_DIR}/deps/deps/lzma-22.01":' 3rdparty/libchdr/libchdr/CMakeLists.txt
#sed -i -e 's:include "Lzma:include "../deps/lzma-22.01/include/Lzma:g' 3rdparty/libchdr/libchdr/src/libchdr_chd.c
# unbundle Vulkan
sed -i -e '/3rdparty\/vulkan-headers/d' cmake/SearchForStuff.cmake
sed -i -e '/target_link_libraries/s:Vulkan-Headers:vulkan:g' pcsx2/CMakeLists.txt
sed -i -e '/target_link_libraries/s:shaderc_shared:shaderc_moronic:g' pcsx2/CMakeLists.txt
%build
# this macro needs 'BuildRequires: memory-constraints'
#limit_build -m 2000
ulimit -Sn 4000
# this might be needed to avoid random builds with forced AVX2 which die on older CPUs
# but adding this forces SSE2 version of GPU plugin that is broken under clang
# -DDISABLE_ADVANCE_SIMD=TRUE \
# it's likely because those geniuses hardcode "-march=native" too…
export UCFLAGS="${UCFLAGS} -fPIC -fno-strict-aliasing -O3 -march=x86-64 -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
# it's never an pcsx2 update without fucking something up in most amateurish way…
export UCFLAGS="${UCFLAGS} -L%{_libdir} -lshaderc_moronic"
%ifarch x86_64
export UCFLAGS="${UCFLAGS} -mtune=generic"
%endif
export ULDFLAGS="-fPIC"
export ULDFLAGS="${ULDFLAGS} -Wl,--gc-sections -Wl,--icf=safe"
%if !0%{?use_lld}
export ULDFLAGS="${ULDFLAGS} -fuse-ld=gold -Wl,--sort-common -Wl,-O1"
export LD=ld.gold
alias ld=gold
%endif
%if 0%{?use_clang}
export CC=clang
export CXX=clang++
#export UCFLAGS="${UCFLAGS} -v -D_GNU_SOURCE -Wno-argument-outside-range"
#export UCFLAGS="${UCFLAGS} -fexceptions -faligned-allocation"
export UCXXFLAGS="${UCFLAGS}"
#export UCXXFLAGS="${UCXXFLAGS} -fpermissive -fcxx-exceptions"
export HOST="$(${CC} -print-target-triple)"
%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
%endif
%if 0%{?use_lto}
%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 %nil
%global _lto_ldlags %nil
%endif
%else
export CC=gcc
export CXX=g++
export UCFLAGS="${UCFLAGS} -ftree-parallelize-loops=4 -ftree-vectorize -fpredictive-commoning"
export UCXXFLAGS="${UCFLAGS} -fpermissive"
export HOST="%{_target_platform}"
%if 0%{?use_lto}
%global _lto_cflags -fuse-linker-plugin %_lto_cflags -ffat-lto-objects -flto-odr-type-merging
%global _lto_ldlags -fuse-linker-plugin -flto=2
%else
%global _lto_cflags %nil
%global _lto_ldlags %nil
%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}"
mkdir build && cd build
cmake \
-DUSE_PCH=OFF -DENABLE_PCH=OFF \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DSKIP_PRECOMPILE_HEADERS=ON \
-DUSE_PRECOMPILED_HEADERS=OFF \
-DCMAKE_INSTALL_PREFIX='%{_prefix}' \
-DCMAKE_BUILD_TYPE='RelWithDebInfo' \
-DPACKAGE_MODE=TRUE \
-DENABLE_TESTS=FALSE \
-DHAVE_PF_RING=TRUE \
-DDISABLE_PCSX2_WRAPPER=TRUE \
-DXDG_STD=TRUE \
-DREBUILD_SHADER=TRUE \
-DPLUGIN_DIR='%{_libdir}/%{dumbname}' \
-DGAMEINDEX_DIR='%{_datadir}/%{dumbname}' \
-DDOC_DIR='%{_docdir}/%{dumbname}' \
-DBIN_DIR='%{_bindir}' \
-DGSDX_LEGACY=FALSE \
-DGLSL_API=TRUE \
-DEGL_API=TRUE \
-DUSE_OPENGL=TRUE \
-DUSE_VULKAN=TRUE \
-DWAYLAND_API=TRUE \
-DCUBEB_API=TRUE \
%if 0%{?opencl}
-DOPENCL_API=TRUE \
%endif
-DDISABLE_BUILD_DATE=TRUE \
-DSDL2_API=TRUE \
-DEXTRA_PLUGINS=TRUE \
%if 0%{?qt_ui}
-DPACKAGE_MODE=FALSE \
-DQT_BUILD=TRUE \
-DGTK2_API=FALSE \
%else
-DPACKAGE_MODE=TRUE \
%if 0%{?gtk3_ui}
-DGTK2_API=FALSE \
%else
-DGTK2_API=TRUE \
%endif
%endif
%if 0%{?use_lto}
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
%else
-DUSE_LTO=FALSE \
-DLTO_PCSX2_CORE=OFF \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
%endif
-DUSE_SYSTEM_LIBS=ON \
-DUSE_SYSTEM_RYML=ON \
-DWITH_SYSTEM_ZLIB=ON \
-DCMAKE_C_STANDARD=17 \
-DCMAKE_C_EXTENSIONS=YES \
-DCMAKE_C_STANDARD_REQUIRED=YES \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_CXX_EXTENSIONS=YES \
-DCMAKE_CXX_STANDARD_REQUIRED=YES \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_LINKER="${LD}" \
-DOPTIMIZATION_FLAG="-fPIC -O3" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_MODULE_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" \
-DCMAKE_STATIC_LINKER_FLAGS="" \
-DUSER_CMAKE_C_FLAGS="${UCFLAGS}" \
-DUSER_CMAKE_CXX_FLAGS="${UCXXFLAGS}" \
-DUSER_CMAKE_LD_FLAGS="${ULDFLAGS}" \
.. || cat CMakeFiles/CMakeError.log
%cmake_build
%install
# actually install this broken crap
# the only thing that is even more retarded is vita3k which is hardcoded to write into binary's directory
%if 0%{?qt_ui}
mkdir -pv %{buildroot}%{_bindir} %{buildroot}%{_datadir}/%{dumbname} %{buildroot}%{_datadir}/applications %{buildroot}%{_datadir}/pixmaps
# move all the garbo from its dump
#mv -v bin/* %{buildroot}%{_datadir}/%{dumbname}/
# commit filthy heresy
mv -v build/bin/pcsx2-qt %{buildroot}%{_datadir}/%{dumbname}/
mv -v build/bin/resources %{buildroot}%{_datadir}/%{dumbname}/
# symlink the myopic binary from datadir into bindir
ln -sv %{_datadir}/%{dumbname}/%{realname}-qt %{buildroot}%{_bindir}/%{realname}
# prefer newer, crisper icon
if [ -f "%{buildroot}%{_datadir}/%{dumbname}/resources/icons/AppIconLarge.png" ]; then
ln -sv ../%{dumbname}/resources/icons/AppIconLarge.png %{buildroot}%{_datadir}/pixmaps/%{dumbname}.png
fi
# search for desktop-file
if [ -f "%{buildroot}%{_datadir}/%{dumbname}/%{dumbname}.desktop" ]; then
mv -v %{buildroot}%{_datadir}/%{dumbname}/%{dumbname}.desktop %{buildroot}%{_datadir}/applications/
else
cp -v .github/workflows/scripts/linux/pcsx2-qt.desktop %{buildroot}%{_datadir}/applications/%{dumbname}.desktop
sed -i -e 's:Categories=.*:Categories=System;Emulator;:' %{buildroot}%{_datadir}/applications/%{dumbname}.desktop
fi
# dump useless docs into the right place
if [ ! -d "%{buildroot}%{_datadir}/doc/%{dumbername}" ]; then
mkdir -p %{buildroot}%{_docdir}/packages
mv -v bin/docs %{buildroot}%{_docdir}/packages/%{name}-%{version}
fi
%else
%cmake_install
%endif
if [ -d "%{buildroot}%{_datadir}/doc/%{dumbername}" ]; then
mkdir -p %{buildroot}%{_docdir}/packages || echo "too bad"
mv %{buildroot}%{_datadir}/doc/%{dumbername} %{buildroot}%{_docdir}/packages/%{name}-%{version}
fi
if [ -d "%{buildroot}%{_datadir}/%{dumbname}/resources/locale" ]; then
mkdir -p %{buildroot}%{_datadir} || echo "too bad"
mv -v %{buildroot}%{_datadir}/%{dumbname}/resources/locale %{buildroot}%{_datadir}/
fi
# move translations to main language dir if there isn't a sublang or delete
# translations not supported by distro at all
for i in $(ls %{buildroot}%{_datadir}/locale | grep _); do
new=$(echo $i | sed "s:_.*::g")
if [ ! -d %{_datadir}/locale/$i ]; then
if [ -d %{_datadir}/locale/$new ]; then
mv %{buildroot}%{_datadir}/locale/$i %{buildroot}%{_datadir}/locale/$new
else
rm -rf %{buildroot}%{_datadir}/locale/$i
fi
fi
done
for lang in $(ls %{buildroot}%{_datadir}/locale); do
mkdir -p %{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES
mv -v %{buildroot}%{_datadir}/locale/${lang}/*.mo %{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES/
done
#install -D -m 644 %{SOURCE1} -t %{buildroot}%{_sysconfdir}/udev/rules.d/
%fdupes -s %{buildroot}
%find_lang pcsx2 || echo "too bad"
%find_lang pcsx2-qt || echo "too bad"
%if !0%{?qt_ui}
%find_lang pcsx2_Main || echo "too bad"
%find_lang pcsx2_Iconized || echo "too bad"
%files lang -f pcsx2_Main.lang -f pcsx2_Iconized.lang
%endif
%files
%defattr(-,root,root)
#%{_sysconfdir}/udev/rules.d/99-direct-access-to-sixaxis-gamepad.rules
%caps(cap_net_raw=eip cap_net_admin=eip) %{_bindir}/%{realname}
#{_bindir}/%{realname}*
#{_libdir}/%{dumbname}
%{_datadir}/%{dumbname}
%{_datadir}/applications/%{dumbname}.desktop
%{_datadir}/pixmaps/%{dumbname}.*
%dir %{_docdir}/packages
%{_docdir}/packages/%{name}-%{version}
%if !0%{?qt_ui}
%{_mandir}/man?/%{dumbname}.*
#{_datadir}/locale/*/LC_MESSAGES/*.mo
%endif
%changelog