#The debug build is disabled by default, please use # --with debug to override %bcond_with debug %global baseversion 252 # # Choices among bundled and system libraries # # Use system expat library instead of the bundled one %define use_system_expat 1 %{?_with_system_expat: %global use_system_expat 1} %{?_without_system_expat: %global use_system_expat 0} # Use system flac library instead of the bundled one %define use_system_flac 1 %{?_with_system_flac: %global use_system_flac 1} %{?_without_system_flac: %global use_system_flac 0} # Use system jpeg library instead of the bundled one %define use_system_jpeg 1 %{?_with_system_jpeg: %global use_system_jpeg 1} %{?_without_system_jpeg: %global use_system_jpeg 0} # Use system lua instead of the bundled one %define use_system_lua 1 %{?_with_system_lua: %global use_system_lua 1} %{?_without_system_lua: %global use_system_lua 0} # Use system portaudio library instead of the bundled one %define use_system_portaudio 1 %{?_with_system_portaudio: %global use_system_portaudio 1} %{?_without_system_portaudio: %global use_system_portaudio 0} # Use system portmidi library instead of the bundled one %define use_system_portmidi 1 %{?_with_system_portmidi: %global use_system_portmidi 1} %{?_without_system_portmidi: %global use_system_portmidi 0} # Use system SDL library instead of the bundled one %define use_system_sdl 1 %{?_with_system_sdl: %global use_system_sdl 1} %{?_without_system_sdl: %global use_system_sdl 0} # Use system sqlite3 library instead of the bundled one %define use_system_sqlite 1 %{?_with_system_sqlite: %global use_system_sqlite 1} %{?_without_system_sqlite: %global use_system_sqlite 0} # Use system utf8proc library instead of the bundled one %define use_system_utf8proc 1 %{?_with_system_utf8proc: %global use_system_utf8proc 1} %{?_without_system_utf8proc: %global use_system_utf8proc 0} # Use system zlib library instead of the bundled one %define use_system_zlib 1 %{?_with_system_zlib: %global use_system_zlib 1} %{?_without_system_zlib: %global use_system_zlib 0} # # Compiler choices # # Use clang/clang++ as default compiler %define use_clang 0 %{?_with_clang: %global use_clang 1} %{?_without_clang: %global use_clang 0} # Force -O3 optimization %define use_opt_O3 0 %{?_with_opt_O3: %global use_opt_O3 1} %{?_without_opt_O3: %global use_opt_O3 0} # Force -Ofast optimization %define use_opt_Ofast 0 %{?_with_opt_Ofast: %global use_opt_Ofast 1} %{?_without_opt_Ofast: %global use_opt_Ofast 1} # LTO requires more than 20GB of RAM for LTO=full, and 6GB for LTO=thin %define use_opt_lto 0 %{?_with_opt_lto: %global use_opt_lto 1} %{?_without_opt_lto: %global use_opt_lto 0} # # Extra package choices # # Use GENie from git %define use_genie_git 1 %{?_with_genie_git: %global use_genie_git 1} %{?_without_genie_git: %global use_genie_git 0} # Extreme Optimization Flags %define use_opt_extreme 0 %{?_with_extreme: %global use_opt_extreme 1} %{?_without_extreme: %global use_opt_extreme 1} # %if %mgaversion >= 9 %define use_system_lua 0 %endif %define use_clang 0 %define use_opt_lto 0 %define use_opt_O3 1 # highest optimization %if %{use_opt_extreme} %define use_system_expat 0 %define use_system_flac 0 %define use_system_jpeg 0 %define use_system_lua 0 %define use_system_portaudio 0 %define use_system_portmidi 0 %define use_system_sdl 0 %define use_system_sqlite 1 %define use_system_utf8proc 0 %define use_system_zlib 1 %define use_opt_lto 1 %define use_opt_Ofast 1 %define use_opt_O3 0 %define use_clang 1 %endif # arm fails with llvm %ifarch %{arm} aarch64 %define use_clang 0 %define use_opt_lto 0 %endif # lto building on 32bit x86 fails due to lack of memory %ifarch %{ix86} %define use_opt_lto 0 %endif # # Adjust conditional build combinations that don't works # # sqlite won't compile with -ffast-math %if %{use_opt_Ofast} %define use_system_sqlite 1 %endif %if %{use_clang} %define mga_lto_ar %{clang_lto_ar} %else %define mga_lto_ar gcc-ar %endif # sqlite won't compile with -ffast-math %if %{use_opt_Ofast} %define use_system_sqlite 1 %endif %ifarch armv7hl # -g causes linker to run out of memory %global debug_package %{nil} %endif Name: mame Version: 0.%{baseversion} Release: %mkrel 1 Group: Games/Arcade Summary: Multiple Arcade Machine Emulator #LGPLv2+: #src/mame/audio/snes_snd.cpp: LGPL (v2 or later) #src/devices/sound/tiasound.cpp: LGPL (v2) (with incorrect FSF address) #src/devices/sound/tiasound.h: LGPL (v2) (with incorrect FSF address) # #ASL 2.0 #3rdparty/bgfx License: GPLv2+ and LGPLv2+ and ASL 2.0 URL: https://mamedev.org/ Source0: https://github.com/mamedev/mame/archive/mame0%{baseversion}.tar.gz Source1: https://mamedev.org/releases/whatsnew_0%{baseversion}.txt # Latest GENie (from https://github.com/bkaradzic/GENie) # export with: git archive -o ../genie-.tar --prefix=genie/ HEAD Source2: genie-git-20220504.tar.gz Patch0: mame-fortify.patch Patch2: mame-0.251-fixhistorypath.patch Patch3: mame-0.224-fix-older-clang.patch Patch4: mame-0.204-clang-lto-thin.patch Patch5: mame-0.204-gcc-lto.patch Patch7: mame-0.204-dont-copy-sdl-includes.patch Patch8: mame-0.204-genie-force-gcc-ar.patch Patch9: mame-0.204-genie-make-more-verbose.patch Patch10: mame-0.247-genie-force-rpm-opt-flags.patch Patch11: mame-0.204-genie-system-lua.patch Patch12: mame-0.204-fix-ini-path.patch Patch13: mame-0.247-genie-dont-force-m64-on-all-archs.patch # from FC Patch14: 0001-Hack-allowing-bgfx-to-initialise-in-absence-of-dx9-s.patch Patch15: 0001-If-combination-of-wayland-videodriver-and-bgfx-video.patch # %if %{use_system_expat} BuildRequires: pkgconfig(expat) %endif %if %{use_system_flac} BuildRequires: pkgconfig(flac) %endif BuildRequires: pkgconfig(fontconfig) %if %{use_system_jpeg} BuildRequires: pkgconfig(libjpeg) %endif BuildRequires: pkgconfig(libuv) %if %{use_system_lua} BuildRequires: pkgconfig(lua) %endif BuildRequires: p7zip %if %{use_system_portaudio} BuildRequires: portaudio-devel %endif %if %{use_system_portmidi} BuildRequires: portmidi-devel %endif BuildRequires: python3 BuildRequires: libqt5-devel BuildRequires: pkgconfig(SDL2_ttf) %if %{use_system_sqlite} BuildRequires: pkgconfig(sqlite3) %endif %if %{use_system_zlib} BuildRequires: pkgconfig(zlib) %endif BuildRequires: pkgconfig(xi) BuildRequires: pkgconfig(xinerama) %if %{use_system_utf8proc} BuildRequires: utf8proc-devel %endif BuildRequires: pkgconfig(libpulse) BuildRequires: python3dist(sphinx) BuildRequires: python3dist(sphinx-rtd-theme) BuildRequires: python3-sphinxcontrib-rsvgconverter %if %{use_clang} BuildRequires: clang BuildRequires: llvm-devel %endif Requires: %{name}-data = %{version}-%{release} #bx and bgfx are not made to be linked to dynamically as per http://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=104437 Provides: bundled(bx) Provides: bundled(bgfx) #fedora contains linenoise package but it is not compatible Provides: bundled(linenoise) #Below have no fedora packages ATM and are very tiny Provides: bundled(lsqlite3) %if ! %{use_system_lua} Provides: bundled(lua) = 5.3.4 %endif Provides: bundled(luafilesystem) Provides: bundled(lua-linenoise) Provides: bundled(lua-zlib) #lzma is not made to be linked dynamically Provides: bundled(lzma-sdk) = 16.04 #softfloat is not made to be linked dynamically Provides: bundled(softfloat) #ldplayer has been turned into a regular mame driver in 0.180 cycle Provides: %{name}-ldplayer = %{version}-%{release} Obsoletes: %{name}-ldplayer < 0.179-4 %description MAME stands for Multiple Arcade Machine Emulator. When used in conjunction with an arcade game's data files (ROMs), MAME will more or less faithfully reproduce that game on a PC. The ROM images that MAME utilizes are "dumped" from arcade games' original circuit-board ROM chips. MAME becomes the "hardware" for the games, taking the place of their original CPUs and support chips. Therefore, these games are NOT simulations, but the actual, original games that appeared in arcades. MAME's purpose is to preserve these decades of video-game history. As gaming technology continues to rush forward, MAME prevents these important "vintage" games from being lost and forgotten. This is achieved by documenting the hardware and how it functions, thanks to the talent of programmers from the MAME team and from other contributors. Being able to play the games is just a nice side-effect, which doesn't happen all the time. MAME strives for emulating the games faithfully. %package tools Summary: Additional tools for MAME Requires: %{name}%{?_isa} = %{version}-%{release} %description tools %{summary}. %package data Summary: Data files used by MAME BuildArch: noarch %description data %{summary}. %package data-software-lists Summary: Software lists used by MAME Requires: %{name}-data >= %{version}-%{release} BuildArch: noarch %description data-software-lists %{summary}. These are split from the main -data subpackage due to relatively large size. %package doc Summary: Documentation for MAME BuildArch: noarch %description doc HTML documentation for MAME. %prep %setup -q -n %{name}-%{name}0%{baseversion} #do not extract system libs or document themes to ensure system ones are used %if %{use_system_sdl} rm -rf \ ./3rdparty/SDL2 \ ./3rdparty/SDL2-override %endif # replace GENie with a newer version from git # (GENie has bundled an internal version of lua-5.3.0, needed for bootstraping itself # which is NOT the same as 3rdparty/lua used by mame, so it'shouldn't be removed). %if %{use_genie_git} rm -rf ./3rdparty/genie tar xvf %{SOURCE2} -C ./3rdparty/ %endif install -pm 644 %{SOURCE1} whatsnew_0%{baseversion}.txt # fix \r find \( -regex '.*\.\(c\|cpp\|fsh\|fx\|h\|lua\|make\|map\|md\|txt\|vsh\|xml\)$' \ -o -wholename ./makefile \) -exec sed -i 's@\r$@@' {} \; %patch0 -p1 -b .fortify # change default historypath, to avoid flooding every dir from which mame is started # from with a file named "history/history.db". %patch2 -p1 -b .fixhistorypath # fix for llvm 3.9 %patch3 -p1 -b .fixolderclang # customize lto for either gcc or clang %if %{use_clang} %patch4 -p1 -b .clanglto %else %patch5 -p1 -b .gcclto %endif # don't copy bundled SDL includes %if %{use_system_sdl} %patch7 -p1 -b .sdl %endif # %if %{use_genie_git} %patch9 -p1 -b .makeverb %patch10 -p1 -b .rpmopt %endif # fix inipath %patch12 -p1 -b .inipath %patch13 -p1 -b .m64 %patch14 -p1 -b .bgx %patch15 -p1 -b .wayland # Create ini files cat > %{name}.ini << EOF # Define multi-user paths artpath %{_datadir}/%{name}/artwork;%{_datadir}/%{name}/effects bgfx_path %{_datadir}/%{name}/bgfx cheatpath %{_datadir}/%{name}/cheat crosshairpath %{_datadir}/%{name}/crosshair ctrlrpath %{_datadir}/%{name}/ctrlr fontpath %{_datadir}/%{name}/fonts hashpath %{_datadir}/%{name}/hash languagepath %{_datadir}/%{name}/language pluginspath %{_datadir}/%{name}/plugins rompath %{_datadir}/%{name}/roms;%{_datadir}/%{name}/chds samplepath %{_datadir}/%{name}/samples # Allow user to override ini settings inipath \$HOME/.%{name}/ini;%{_sysconfdir}/%{name} # Set paths for local storage cfg_directory \$HOME/.%{name}/cfg comment_directory \$HOME/.%{name}/comments diff_directory \$HOME/.%{name}/diff input_directory \$HOME/.%{name}/inp nvram_directory \$HOME/.%{name}/nvram snapshot_directory \$HOME/.%{name}/snap state_directory \$HOME/.%{name}/sta # %{vendor} custom defaults video opengl autosave 1 EOF %build # rebuild GENie targets (use two passes) %if %{use_genie_git} (cd 3rdparty/genie make CFLAGS="$RPM_OPT_FLAGS" VERBOSE=1 SILENT= rebuild ./bin/linux/genie embed make CFLAGS="$RPM_OPT_FLAGS" VERBOSE=1 SILENT= projgen make CFLAGS="$RPM_OPT_FLAGS" -B VERBOSE=1 SILENT= -C build/gmake.linux all make CFLAGS="$RPM_OPT_FLAGS" VERBOSE=1 SILENT= projgen ) %else #ensure genie uses $RPM_OPT_FLAGS and $RPM_LD_FLAGS sed -i "s@-Wall -Wextra -Os@$RPM_OPT_FLAGS@" 3rdparty/genie/build/gmake.linux/genie.make sed -i "s@\. -s@\. $RPM_LD_FLAGS@" 3rdparty/genie/build/gmake.linux/genie.make %endif # rename various license files so that they can be installed with %%license mv artwork/LICENSE LICENSE.CC0 mv bgfx/LICENSE LICENSE.BSD3 mv plugins/json/LICENSE LICENSE.MIT # MAME_FLAGS="NOWERROR=1 \ VERBOSE=1 \ SILENT= \ %if %{use_opt_O3} OPTIMIZE=3 \ %endif %if %{use_opt_Ofast} OPTIMIZE=fast \ %endif %if !%{use_opt_O3} && !%{use_opt_Ofast} OPTIMIZE=2 \ %endif %if %{use_system_expat} USE_SYSTEM_LIB_EXPAT=1 \ %endif %if %{use_system_zlib} USE_SYSTEM_LIB_ZLIB=1 \ %endif %if %{use_system_jpeg} USE_SYSTEM_LIB_JPEG=1 \ %endif %if %{use_system_flac} USE_SYSTEM_LIB_FLAC=1 \ %endif %if %{use_system_lua} USE_SYSTEM_LIB_LUA=1 \ %endif %if %{use_system_sqlite} USE_SYSTEM_LIB_SQLITE3=1 \ %endif %if %{use_system_portaudio} USE_SYSTEM_LIB_PORTAUDIO=1 \ %endif %if %{use_system_portmidi} USE_SYSTEM_LIB_PORTMIDI=1 \ %endif %if %{use_system_utf8proc} USE_SYSTEM_LIB_UTF8PROC=1 \ %endif %if %{use_system_sdl} USE_BUNDLED_SDL2=0 \ %else USE_BUNDLED_SDL2=1 \ %endif %if %{use_opt_lto} LTO=1 \ OVERRIDE_LD=ld.gold \ AR=%{mga_lto_ar} \ %endif %if %{use_clang} OVERRIDE_CC=clang \ OVERRIDE_CXX=clang++ \ %endif SDL_INI_PATH=%{_sysconfdir}/%{name}\;" #standard -g causes builder to run out of memory %ifarch armv7hl RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS | sed "s@-g@-g0@g") RPM_LD_FLAGS="$RPM_LD_FLAGS -Wl,--no-keep-memory,--reduce-memory-overheads,--hash-size=31" %else RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS | sed "s@-g@-g1@g") %endif %ifarch %{ix86} RPM_LD_FLAGS="$RPM_LD_FLAGS -Wl,--no-keep-memory,--reduce-memory-overheads" %endif %if %{use_opt_O3} RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS | sed "s@-O2@-O3@g") RPM_LD_FLAGS=$(echo $RPM_LD_FLAGS | sed "s@-Wl,-O1@-Wl,-O3@g") %endif %if %{use_opt_Ofast} RPM_OPT_FLAGS="-Ofast -fomit-frame-pointer -g1" RPM_LD_FLAGS=$(echo $RPM_LD_FLAGS | sed "s@-O1@-O3@g") %endif %if %{use_opt_lto} RPM_LD_FLAGS="$RPM_LD_FLAGS -fuse-ld=gold" # AR is replicated here to avoid some miss export AR=%{mga_lto_ar} %endif export RPM_OPT_FLAGS export RPM_LD_FLAGS %if %{with debug} %make_build $MAME_FLAGS \ DEBUG=1 \ TOOLS=1 \ OPT_FLAGS="$RPM_OPT_FLAGS" \ LDOPTS="$RPM_LD_FLAGS" -j4 %else %make_build $MAME_FLAGS \ TOOLS=1 \ OPT_FLAGS="$RPM_OPT_FLAGS" \ %if %{use_opt_lto} LDOPTS="$RPM_LD_FLAGS $RPM_OPT_FLAGS" %else LDOPTS="$RPM_LD_FLAGS" %endif %endif pushd docs %make_build html popd %install # create directories install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{name} for folder in cfg comments diff ini inp memcard nvram snap sta do install -d $RPM_BUILD_ROOT%{_sysconfdir}/skel/.%{name}/$folder done install -d $RPM_BUILD_ROOT%{_bindir} for folder in artwork bgfx chds cheats ctrlr effects fonts hash language \ plugins hlsl keymaps roms samples shader do install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/$folder done install -d $RPM_BUILD_ROOT%{_mandir}/man1 install -d $RPM_BUILD_ROOT%{_mandir}/man6 # install files install -pm 644 %{name}.ini $RPM_BUILD_ROOT%{_sysconfdir}/%{name} %if %{with debug} install -pm 755 %{name}d $RPM_BUILD_ROOT%{_bindir}/%{name}d || \ install -pm 755 %{name}64d $RPM_BUILD_ROOT%{_bindir}/%{name}d %else install -pm 755 %{name} $RPM_BUILD_ROOT%{_bindir}/%{name} || \ install -pm 755 %{name}64 $RPM_BUILD_ROOT%{_bindir}/%{name} %endif install -pm 755 castool chdman floptool imgtool jedutil ldresample ldverify \ nltool nlwav pngcmp romcmp unidasm $RPM_BUILD_ROOT%{_bindir} for tool in regrep split srcclean do install -pm 755 $tool $RPM_BUILD_ROOT%{_bindir}/%{name}-$tool done pushd artwork find -type d -exec install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/artwork/{} \; find -type f -exec install -pm 644 {} $RPM_BUILD_ROOT%{_datadir}/%{name}/artwork/{} \; popd pushd bgfx find -type d -exec install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/bgfx/{} \; find -type f -exec install -pm 644 {} $RPM_BUILD_ROOT%{_datadir}/%{name}/bgfx/{} \; popd install -pm 644 hash/* $RPM_BUILD_ROOT%{_datadir}/%{name}/hash install -pm 644 hlsl/*.fx $RPM_BUILD_ROOT%{_datadir}/%{name}/hlsl install -pm 644 keymaps/* $RPM_BUILD_ROOT%{_datadir}/%{name}/keymaps pushd language find -type d -exec install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/language/{} \; find -type f -name \*.mo -exec install -pm 644 {} $RPM_BUILD_ROOT%{_datadir}/%{name}/language/{} \; popd pushd plugins find -type d -exec install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins/{} \; find -type f -exec install -pm 644 {} $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins/{} \; popd pushd src/osd/modules/opengl install -pm 644 shader/*.?sh $RPM_BUILD_ROOT%{_datadir}/%{name}/shader popd pushd docs/man install -pm 644 castool.1 chdman.1 imgtool.1 floptool.1 jedutil.1 ldresample.1 \ ldverify.1 romcmp.1 $RPM_BUILD_ROOT%{_mandir}/man1 install -pm 644 mame.6 $RPM_BUILD_ROOT%{_mandir}/man6 popd find $RPM_BUILD_ROOT%{_datadir}/%{name} -name LICENSE -exec rm {} \; %files %config(noreplace) %{_sysconfdir}/%{name}/%{name}.ini %dir %{_sysconfdir}/%{name} %{_sysconfdir}/skel/.%{name} %if %{with debug} %{_bindir}/%{name}d %else %{_bindir}/%{name} %endif %{_mandir}/man6/mame.6* %files tools %{_bindir}/castool %{_bindir}/chdman %{_bindir}/floptool %{_bindir}/imgtool %{_bindir}/jedutil %{_bindir}/ldresample %{_bindir}/ldverify %{_bindir}/nltool %{_bindir}/nlwav %{_bindir}/pngcmp %{_bindir}/%{name}-regrep %{_bindir}/romcmp %{_bindir}/%{name}-split %{_bindir}/%{name}-srcclean %{_bindir}/unidasm %{_mandir}/man1/castool.1* %{_mandir}/man1/chdman.1* %{_mandir}/man1/floptool.1* %{_mandir}/man1/imgtool.1* %{_mandir}/man1/jedutil.1* %{_mandir}/man1/ldresample.1* %{_mandir}/man1/ldverify.1* %{_mandir}/man1/romcmp.1* %files data %doc README.md whatsnew*.txt %license LICENSE.BSD3 LICENSE.CC0 LICENSE.MIT %{_datadir}/%{name} %exclude %{_datadir}/%{name}/hash/* %files data-software-lists %{_datadir}/%{name}/hash/* %files doc %doc docs/build/html