summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/emulators/mame
diff options
context:
space:
mode:
authorAndersonTorres <torres.anderson.85@protonmail.com>2022-02-15 23:28:16 -0300
committerAndersonTorres <torres.anderson.85@protonmail.com>2022-02-16 01:38:20 -0300
commit8d65e832f0a18f60e2040940c80d96373ac8b88c (patch)
tree3d6ade66b2a81403e3852b80b9e7c660699b6ed6 /pkgs/applications/emulators/mame
parent19574af0af3ffaf7c9e359744ed32556f34536bd (diff)
Move misc/emulators to applications/emulators - part 1
Emulators form a class by themselves. So, they should be moved to applications/.
Diffstat (limited to 'pkgs/applications/emulators/mame')
-rw-r--r--pkgs/applications/emulators/mame/default.nix105
-rw-r--r--pkgs/applications/emulators/mame/emuopts.patch29
2 files changed, 134 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/mame/default.nix b/pkgs/applications/emulators/mame/default.nix
new file mode 100644
index 000000000000..e0915703003a
--- /dev/null
+++ b/pkgs/applications/emulators/mame/default.nix
@@ -0,0 +1,105 @@
+{ lib
+, stdenv
+, alsa-lib
+, CoreAudioKit
+, fetchFromGitHub
+, fontconfig
+, ForceFeedback
+, installShellFiles
+, libpcap
+, libpulseaudio
+, libXi
+, libXinerama
+, makeDesktopItem
+, makeWrapper
+, pkg-config
+, python3
+, qtbase
+, SDL2
+, SDL2_ttf
+, which
+}:
+
+let
+ desktopItem = makeDesktopItem {
+ name = "MAME";
+ exec = "mame${lib.optionalString stdenv.is64bit "64"}";
+ desktopName = "MAME";
+ genericName = "MAME is a multi-purpose emulation framework";
+ categories = "System;Emulator;";
+ };
+
+ dest = "$out/opt/mame";
+in
+stdenv.mkDerivation rec {
+ pname = "mame";
+ version = "0.239";
+
+ src = fetchFromGitHub {
+ owner = "mamedev";
+ repo = "mame";
+ rev = "mame${builtins.replaceStrings [ "." ] [ "" ] version}";
+ sha256 = "sha256-svclBaFkp4d6db+zWZNvZP8vWIFz/7M5N1M6WseOFEk=";
+ };
+
+ hardeningDisable = [ "fortify" ];
+ NIX_CFLAGS_COMPILE = [ "-Wno-error=maybe-uninitialized" "-Wno-error=missing-braces" ];
+
+ makeFlags = [
+ "TOOLS=1"
+ "USE_LIBSDL=1"
+ "CC=${stdenv.cc.targetPrefix}cc"
+ "CXX=${stdenv.cc.targetPrefix}c++"
+ ];
+
+ dontWrapQtApps = true;
+
+ # https://docs.mamedev.org/initialsetup/compilingmame.html
+ buildInputs =
+ [ SDL2 SDL2_ttf qtbase ]
+ ++ lib.optionals stdenv.isLinux [ alsa-lib libpulseaudio libXinerama libXi fontconfig ]
+ ++ lib.optionals stdenv.isDarwin [ libpcap CoreAudioKit ForceFeedback ];
+
+ nativeBuildInputs = [ python3 pkg-config which makeWrapper installShellFiles ];
+
+ # by default MAME assumes that paths with stock resources
+ # are relative and that you run MAME changing to
+ # install directory, so we add absolute paths here
+ patches = [
+ ./emuopts.patch
+ ];
+
+ postPatch = ''
+ substituteInPlace src/emu/emuopts.cpp \
+ --subst-var-by mame ${dest}
+ '';
+
+ installPhase = ''
+ make -f dist.mak PTR64=${lib.optionalString stdenv.is64bit "1"}
+ mkdir -p ${dest}
+ mv build/release/*/Release/mame/* ${dest}
+
+ mkdir -p $out/bin
+ find ${dest} -maxdepth 1 -executable -type f -exec mv -t $out/bin {} \;
+ install -Dm755 src/osd/sdl/taputil.sh $out/bin/taputil.sh
+
+ installManPage ${dest}/docs/man/*.1 ${dest}/docs/man/*.6
+
+ mv artwork plugins samples ${dest}
+ '' + lib.optionalString stdenv.isLinux ''
+ mkdir -p $out/share
+ ln -s ${desktopItem}/share/applications $out/share
+ '';
+
+ enableParallelBuilding = true;
+
+ meta = with lib; {
+ description = "Is a multi-purpose emulation framework";
+ homepage = "https://www.mamedev.org/";
+ license = with licenses; [ bsd3 gpl2Plus ];
+ platforms = platforms.unix;
+ maintainers = with maintainers; [ thiagokokada ];
+ # macOS needs more time to build
+ timeout = 24 * 3600;
+ };
+}
diff --git a/pkgs/applications/emulators/mame/emuopts.patch b/pkgs/applications/emulators/mame/emuopts.patch
new file mode 100644
index 000000000000..b85291f52f74
--- /dev/null
+++ b/pkgs/applications/emulators/mame/emuopts.patch
@@ -0,0 +1,29 @@
+diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp
+index c42fcef848..d1bddae060 100644
+--- a/src/emu/emuopts.cpp
++++ b/src/emu/emuopts.cpp
+@@ -36,16 +36,16 @@ const options_entry emu_options::s_option_entries[] =
+ { nullptr, nullptr, OPTION_HEADER, "CORE SEARCH PATH OPTIONS" },
+ { OPTION_HOMEPATH, ".", OPTION_STRING, "path to base folder for plugin data (read/write)" },
+ { OPTION_MEDIAPATH ";rp;biospath;bp", "roms", OPTION_STRING, "path to ROM sets and hard disk images" },
+- { OPTION_HASHPATH ";hash_directory;hash", "hash", OPTION_STRING, "path to software definition files" },
+- { OPTION_SAMPLEPATH ";sp", "samples", OPTION_STRING, "path to audio sample sets" },
+- { OPTION_ARTPATH, "artwork", OPTION_STRING, "path to artwork files" },
+- { OPTION_CTRLRPATH, "ctrlr", OPTION_STRING, "path to controller definitions" },
+- { OPTION_INIPATH, ".;ini;ini/presets", OPTION_STRING, "path to ini files" },
+- { OPTION_FONTPATH, ".", OPTION_STRING, "path to font files" },
++ { OPTION_HASHPATH ";hash_directory;hash", "hash;@mame@/hash", OPTION_STRING, "path to software definition files" },
++ { OPTION_SAMPLEPATH ";sp", "samples;@mame@/samples", OPTION_STRING, "path to audio sample sets" },
++ { OPTION_ARTPATH, "artwork;@mame@/artwork", OPTION_STRING, "path to artwork files" },
++ { OPTION_CTRLRPATH, "ctrlr;@mame@/ctrlr", OPTION_STRING, "path to controller definitions" },
++ { OPTION_INIPATH, ".;ini;ini/presets;@mame@/ini/presets", OPTION_STRING, "path to ini files" },
++ { OPTION_FONTPATH, ".;@mame@", OPTION_STRING, "path to font files" },
+ { OPTION_CHEATPATH, "cheat", OPTION_STRING, "path to cheat files" },
+ { OPTION_CROSSHAIRPATH, "crosshair", OPTION_STRING, "path to crosshair files" },
+- { OPTION_PLUGINSPATH, "plugins", OPTION_STRING, "path to plugin files" },
+- { OPTION_LANGUAGEPATH, "language", OPTION_STRING, "path to UI translation files" },
++ { OPTION_PLUGINSPATH, "plugins;@mame@/plugins", OPTION_STRING, "path to plugin files" },
++ { OPTION_LANGUAGEPATH, "language;@mame@/language", OPTION_STRING, "path to UI translation files" },
+ { OPTION_SWPATH, "software", OPTION_STRING, "path to loose software" },
+
+ // output directory options