nixpkgs/pkgs/misc/emulators/mame/default.nix

88 lines
2.5 KiB
Nix
Raw Normal View History

2019-12-06 21:43:40 +01:00
{ stdenv, mkDerivation, fetchFromGitHub, makeDesktopItem, makeWrapper
2019-12-26 18:58:15 +01:00
, python, pkgconfig, SDL2, SDL2_ttf, alsaLib, which, qtbase, libXinerama
2020-03-27 07:17:27 +01:00
, libpcap, CoreAudioKit, ForceFeedback
2019-12-26 18:58:15 +01:00
, installShellFiles }:
2019-10-30 20:29:51 +01:00
2020-03-27 07:17:27 +01:00
with stdenv;
2019-10-30 20:29:51 +01:00
let
majorVersion = "0";
2020-05-19 21:53:33 +02:00
minorVersion = "221";
2019-10-30 20:29:51 +01:00
desktopItem = makeDesktopItem {
name = "MAME";
2020-03-27 07:17:27 +01:00
exec = "mame${lib.optionalString stdenv.is64bit "64"}";
2019-10-30 20:29:51 +01:00
desktopName = "MAME";
genericName = "MAME is a multi-purpose emulation framework";
categories = "System;Emulator;";
};
2019-12-06 21:43:40 +01:00
dest = "$out/opt/mame";
2019-10-30 20:29:51 +01:00
in mkDerivation {
pname = "mame";
version = "${majorVersion}.${minorVersion}";
src = fetchFromGitHub {
owner = "mamedev";
repo = "mame";
rev = "mame${majorVersion}${minorVersion}";
2020-05-19 21:53:33 +02:00
sha256 = "1pqwa5qcrk0wgbyns6fkv7j3pn7byf216cixc3phhhgvfidgr8ww";
2019-10-30 20:29:51 +01:00
};
hardeningDisable = [ "fortify" ];
2020-03-27 07:17:27 +01:00
NIX_CFLAGS_COMPILE = [ "-Wno-error=maybe-uninitialized" "-Wno-error=missing-braces" ];
2019-10-30 20:29:51 +01:00
2020-03-27 07:17:27 +01:00
makeFlags = [
"TOOLS=1"
"USE_LIBSDL=1"
]
++ lib.optionals stdenv.cc.isClang [ "CC=clang" "CXX=clang++" ]
;
2019-10-30 20:29:51 +01:00
2019-12-06 21:43:40 +01:00
dontWrapQtApps = true;
2020-03-27 07:17:27 +01:00
buildInputs =
[ SDL2 SDL2_ttf qtbase libXinerama ]
++ lib.optional stdenv.isLinux alsaLib
++ lib.optionals stdenv.isDarwin [ libpcap CoreAudioKit ForceFeedback ]
;
2019-12-26 18:58:15 +01:00
nativeBuildInputs = [ python pkgconfig which makeWrapper installShellFiles ];
2019-10-30 20:29:51 +01:00
2019-12-06 21:43:40 +01:00
# 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 ];
2019-10-30 20:29:51 +01:00
2019-12-06 21:43:40 +01:00
postPatch = ''
substituteInPlace src/emu/emuopts.cpp \
--subst-var-by mame ${dest}
'';
installPhase = ''
make -f dist.mak PTR64=${stdenv.lib.optionalString stdenv.is64bit "1"}
mkdir -p ${dest}
mv build/release/*/Release/mame/* ${dest}
2019-10-30 20:29:51 +01:00
mkdir -p $out/bin
2019-12-06 21:43:40 +01:00
find ${dest} -maxdepth 1 -executable -type f -exec mv -t $out/bin {} \;
install -Dm755 src/osd/sdl/taputil.sh $out/bin/taputil.sh
2019-10-30 20:29:51 +01:00
2019-12-26 18:58:15 +01:00
installManPage ${dest}/docs/man/*.1 ${dest}/docs/man/*.6
2019-12-06 21:43:40 +01:00
mv artwork plugins samples ${dest}
2020-03-27 07:17:27 +01:00
'' + lib.optionalString stdenv.isLinux ''
2019-10-30 20:29:51 +01:00
mkdir -p $out/share
ln -s ${desktopItem}/share/applications $out/share
'';
2020-03-27 07:17:27 +01:00
meta = with lib; {
2019-10-30 20:29:51 +01:00
description = "Is a multi-purpose emulation framework";
homepage = "https://www.mamedev.org/";
2019-10-30 20:29:51 +01:00
license = with licenses; [ bsd3 gpl2Plus ];
2020-03-27 07:17:27 +01:00
platforms = platforms.unix;
# makefile needs fixes for install target
badPlatforms = [ "aarch64-linux" ];
2019-10-30 20:29:51 +01:00
maintainers = with maintainers; [ gnidorah ];
};
}