SDL_compat: Fix on Darwin

This commit is contained in:
OPNA2608 2022-09-08 23:05:48 +02:00 committed by Peter Hoeg
parent 7fa06a5398
commit 693b87b982
2 changed files with 23 additions and 4 deletions

View file

@ -1,9 +1,12 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, pkg-config
, SDL2
, libiconv
, Cocoa
, libGLSupported ? lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms
, openglSupport ? libGLSupported
, libGL
@ -25,9 +28,20 @@ stdenv.mkDerivation rec {
hash = "sha256-PDGlMI8q74JaqMQ5oX9Zt5CEr7frFQWECbuwq5g25eg=";
};
patches = optionals stdenv.hostPlatform.isDarwin [
# Fix broken install name in dylib, https://github.com/libsdl-org/sdl12-compat/issues/194
# Remove when bump > 1.2.52
(fetchpatch {
name = "SDL_compat-fix-install-name.patch";
url = "https://github.com/libsdl-org/sdl12-compat/commit/5642d47ae489f2eb362cece2464ecc466a700ed5.patch";
sha256 = "sha256-kQ5H8gXjTZVHHRF6UpgXKl3NIy87iULcc2iCsYt5Hqo=";
})
];
nativeBuildInputs = [ cmake pkg-config ];
propagatedBuildInputs = [ SDL2 ]
++ optionals stdenv.hostPlatform.isDarwin [ libiconv Cocoa ]
++ optionals openglSupport [ libGL libGLU ];
enableParallelBuilding = true;
@ -35,15 +49,18 @@ stdenv.mkDerivation rec {
setupHook = ../SDL/setup-hook.sh;
postFixup = ''
for lib in $out/lib/*.so* ; do
for lib in $out/lib/*${stdenv.hostPlatform.extensions.sharedLibrary}* ; do
if [[ -L "$lib" ]]; then
patchelf --set-rpath "$(patchelf --print-rpath $lib):${makeLibraryPath propagatedBuildInputs}" "$lib"
${if stdenv.hostPlatform.isDarwin then ''
install_name_tool ${lib.strings.concatMapStrings (x: " -add_rpath ${makeLibraryPath [x]} ") propagatedBuildInputs} "$lib"
'' else ''
patchelf --set-rpath "$(patchelf --print-rpath $lib):${makeLibraryPath propagatedBuildInputs}" "$lib"
''}
fi
done
'';
meta = with lib; {
broken = stdenv.isDarwin;
description = "A cross-platform multimedia library - build SDL 1.2 applications against 2.0";
homepage = "https://www.libsdl.org/";
license = licenses.zlib;

View file

@ -21383,7 +21383,9 @@ with pkgs;
libGLU = null;
});
SDL_compat = callPackage ../development/libraries/SDL_compat { };
SDL_compat = callPackage ../development/libraries/SDL_compat {
inherit (darwin.apple_sdk.frameworks) Cocoa;
};
SDL = SDL_classic;