Skip to content

Commit

Permalink
libretro.mame*: fix build on Darwin
Browse files Browse the repository at this point in the history
It was found out in the course of NixOS#102078 that the libretro.mame*
packages did not build on macOS, both because of an unconditional
dependency on alsa-lib (which is exclusive to Linux) and references
to GCC scattered across makefiles.

This commit makes alsa-lib a dependency only on Linux, and tries to
force usage of the generic `cc`/`c++` commands.  Ideally we'd refer
to the `$CC` and `$CXX` environment variables, but that seems to
introduce recursive expansion problems for make.

Thanks to @SuperSandro2000 for suggestions and actual testing.
  • Loading branch information
AluisioASG committed Oct 31, 2020
1 parent f28c4a1 commit 8a0d39f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkgs/misc/emulators/retroarch/cores.nix
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,15 @@ in with stdenv.lib.licenses;
description = "Port of MAME to libretro";
license = gpl2Plus;

extraBuildInputs = [ alsaLib libGLU libGL portaudio python27 xorg.libX11 ];
extraBuildInputs = [ libGLU libGL portaudio python27 xorg.libX11 ]
++ stdenv.lib.optional stdenv.isLinux alsaLib;
postPatch = ''
# Prevent the failure during the parallel building of:
# make -C 3rdparty/genie/build/gmake.linux -f genie.make obj/Release/src/host/lua-5.3.0/src/lgc.o
mkdir -p 3rdparty/genie/build/gmake.linux/obj/Release/src/host/lua-5.3.0/src
'';
makefile = "Makefile.libretro";
makeFlags = [ "CC=cc" "CXX=c++" "LD=c++" ];
};

mame2000 = mkLibRetroCore rec {
Expand Down Expand Up @@ -606,7 +608,8 @@ in with stdenv.lib.licenses;
description = "Port of MAME ~2010 to libretro";
license = gpl2Plus;
makefile = "Makefile";
makeFlags = stdenv.lib.optionals stdenv.hostPlatform.isAarch64 [ "PTR64=1" "ARM_ENABLED=1" "X86_SH2DRC=0" "FORCE_DRC_C_BACKEND=1" ];
makeFlags = [ "CC_AS=cc" "CC=c++" "LD=c++" ]
++ stdenv.lib.optionals stdenv.hostPlatform.isAarch64 [ "PTR64=1" "ARM_ENABLED=1" "X86_SH2DRC=0" "FORCE_DRC_C_BACKEND=1" ];
};

mame2015 = mkLibRetroCore rec {
Expand All @@ -619,8 +622,9 @@ in with stdenv.lib.licenses;
description = "Port of MAME ~2015 to libretro";
license = gpl2Plus;
extraNativeBuildInputs = [ python27 ];
extraBuildInputs = [ alsaLib ];
extraBuildInputs = stdenv.lib.optional stdenv.isLinux alsaLib;
makefile = "Makefile";
makeFlags = [ "REALCC=cc" "NATIVECC=c++" "CXX=c++" ];
};

mame2016 = mkLibRetroCore rec {
Expand All @@ -640,11 +644,15 @@ in with stdenv.lib.licenses;
description = "Port of MAME ~2016 to libretro";
license = gpl2Plus;
extraNativeBuildInputs = [ python27 ];
extraBuildInputs = [ alsaLib ];
extraBuildInputs = stdenv.lib.optional stdenv.isLinux alsaLib;
postPatch = ''
# Prevent the failure during the parallel building of:
# make -C 3rdparty/genie/build/gmake.linux -f genie.make obj/Release/src/host/lua-5.3.0/src/lgc.o
mkdir -p 3rdparty/genie/build/gmake.linux/obj/Release/src/host/lua-5.3.0/src
# Don't override the toolchain. While makefile allows us to pass
# OVERRIDE_* to fix this, Makefile.libreto (which is our entry
# point) does not pass those along to makefile.
sed -ri '/^(CC|CXX|LD)\s*:?=/d' makefile 3rdparty/genie/build/*/genie.make
'';
};

Expand Down

1 comment on commit 8a0d39f

@SuperSandro2000
Copy link

@SuperSandro2000 SuperSandro2000 commented on 8a0d39f Oct 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad I could help out ❤️

Please sign in to comment.