File desmume-git.spec of Package desmume-git

#
# spec file
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2013 Stefan Elser <stefan@fam-elser.de>
#
# 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 https://bugs.opensuse.org/
#


%define realname   desmume
%define srcext   tar.xz
%global use_clang 0
%global use_lld 0
%global use_lto 0
%define __builder ninja

Name:           %{realname}-git
Version:        20240214T082057
Release:        0
License:        GPL-2.0-only
Summary:        The Last Nintendo DS Emulator, bleeding edge
URL:            http://desmume.org/
Group:          System/Emulators/Other
Source0:        %{realname}-%{version}.%{srcext}
Source1:        %{realname}.sh
Conflicts:      desmume
Conflicts:      desmume-svn
BuildRequires:  gtk3-devel
BuildRequires:  xz
#BuildRequires:  libglade2-devel
#BuildRequires:  gtkglext-devel
%if "%{__builder}" == "ninja"
BuildRequires:  ninja
%endif
%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:  SDL2-devel
BuildRequires:  cmake
BuildRequires:  intltool
BuildRequires:  tinyxml-devel
#BuildRequires:	agg-devel
BuildRequires:  Mesa-devel
BuildRequires:  alsa-devel
BuildRequires:  libOSMesa-devel
BuildRequires:  openal-devel
BuildRequires:  soundtouch-devel
#BuildRequires:  libagg-devel
BuildRequires:  lua53-devel
#BuildRequires:	lua53-luajit-devel
BuildRequires:  dos2unix
BuildRequires:  fdupes
BuildRequires:  libpcap-devel
BuildRequires:  meson
BuildRequires:  update-desktop-files
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(post): hicolor-icon-theme
Requires(post): update-desktop-files
Requires(postun):hicolor-icon-theme
Requires(postun):update-desktop-files

%description
DeSmuME is a Nintendo DS emulator under GNU GPL.
With it DS games are perfectly playable.

This is a build of bleeding edge from git snapshot.


#{lang_package}
%prep
%setup -q -n %{realname}-%{version}
dos2unix COPYING
dos2unix AUTHORS
chmod -x COPYING AUTHORS

%build
# this macro needs 'BuildRequires: memory-constraints'
#limit_build -m 3072
ulimit -Sn 4000
# this emulator is very crashy and its code is riddled with warnings of all kinds
UCFLAGS="-fPIC -O3 -march=x86-64 -mtune=generic -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
# don't commit suicide out of shame!
export UCFLAGS="${UCFLAGS} -Wno-error=int-conversion"
export ULDFLAGS="-fPIC -Wl,--gc-sections -Wl,-O1 -Wl,--icf=safe"
%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
%if 0%{?use_clang}
export CC=clang
export CXX=clang++
#export CPP='clang -E' LD=ld.lld AR=llvm-ar AS=llvm-as NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump RANLIB=llvm-ranlib
export UCFLAGS="${UCFLAGS} -v -fbracket-depth=1024 -fconstexpr-depth=1024 -relocatable-pch"
%ifarch x86_64
export UCFLAGS="${UCFLAGS} -fglobal-isel"
%endif
#export UCFLAGS="${UCFLAGS} -D_GNU_SOURCE -fexceptions"
export UCXXFLAGS="${UCFLAGS} -fpermissive"
#export UCXXFLAGS="${UCFLAGS} -fcxx-exceptions"
export HOST="$(${CC} -print-target-triple)"
%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=16 -ftree-vectorize -fvect-cost-model=unlimited -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}"

cd src/frontend/posix
%meson \
	-Dopenal=true \
	-Dfrontend-gtk=true \
	-Dfrontend-cli=true \
	-Dwifi=true
%meson_build

%install
cd src/frontend/posix
%meson_install
# forcing settings for maximum performance
#mv -v %{buildroot}%{_bindir}/%{realname} %{buildroot}%{_bindir}/%{realname}-gtk
#install -D -m 755 %{SOURCE1} %{buildroot}%{_bindir}/%{realname}
# crutch for mishandled naming for mo-files
#for i in %{buildroot}%{_datadir}/locale/*; do
#	mv -v ${i}/LC_MESSAGES/.mo ${i}/LC_MESSAGES/%{realname}.mo
#done
#suse_update_desktop_file -r -G %{realname} org.desmume.DeSmuME.desktop System Emulator
%fdupes -s %{buildroot}
#find_lang %{realname}

#files lang -f %{realname}.lang

%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun

%files
%defattr(-,root,root)
%doc AUTHORS COPYING README.LIN
%{_bindir}/%{realname}*
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/scalable/apps/*.svg
%{_datadir}/metainfo/*.xml
#{_datadir}/%{realname}
%{_mandir}/man?/*%{realname}*

%changelog
openSUSE Build Service is sponsored by