summary refs log tree commit diff
path: root/pkgs/development/libraries/SDL2
diff options
context:
space:
mode:
authorJan Malakhovski <oxij@oxij.org>2018-03-05 20:12:44 +0000
committerJan Malakhovski <oxij@oxij.org>2018-03-06 15:43:27 +0000
commitf114118842e19ced171fd634d6ff70a92746f2cb (patch)
tree7bee708aa9e28907e3035ebc4a6205bc05dceda5 /pkgs/development/libraries/SDL2
parent6166027ca88eab5372508f0fd3f3b6bc51e91a19 (diff)
downloadnixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.tar
nixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.tar.gz
nixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.tar.bz2
nixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.tar.lz
nixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.tar.xz
nixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.tar.zst
nixpkgs-f114118842e19ced171fd634d6ff70a92746f2cb.zip
SDL, SDL2: don't link statically to any of the inputs
Diffstat (limited to 'pkgs/development/libraries/SDL2')
-rw-r--r--pkgs/development/libraries/SDL2/default.nix43
1 files changed, 30 insertions, 13 deletions
diff --git a/pkgs/development/libraries/SDL2/default.nix b/pkgs/development/libraries/SDL2/default.nix
index 04e187a8256..ca88d42b84c 100644
--- a/pkgs/development/libraries/SDL2/default.nix
+++ b/pkgs/development/libraries/SDL2/default.nix
@@ -21,14 +21,10 @@ assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null);
 
 let
 
-  # XXX: By default, SDL wants to dlopen() PulseAudio, in which case
-  # we must arrange to add it to its RPATH; however, `patchelf' seems
-  # to fail at doing this, hence `--disable-pulseaudio-shared'.
   configureFlagsFun = attrs: [
-      "--disable-oss" "--disable-x11-shared" "--disable-wayland-shared"
-      "--disable-pulseaudio-shared" "--disable-alsa-shared"
-    ] ++ optional alsaSupport "--with-alsa-prefix=${attrs.alsaLib.out}/lib"
-      ++ optional (!x11Support) "--without-x";
+    "--disable-oss"
+  ] ++ optional (!x11Support) "--without-x"
+    ++ optional alsaSupport "--with-alsa-prefix=${attrs.alsaLib.out}/lib";
 
 in
 
@@ -48,18 +44,17 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
 
-  # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated.
   propagatedBuildInputs = [ libiconv ]
+    ++ optional  dbusSupport dbus
+    ++ optional  udevSupport udev
     ++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]
     ++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
+    ++ optional  alsaSupport alsaLib
     ++ optional  pulseaudioSupport libpulseaudio;
 
   buildInputs = [ audiofile ]
-    ++ optional openglSupport libGL
-    ++ optional alsaSupport alsaLib
-    ++ optional dbusSupport dbus
-    ++ optional udevSupport udev
-    ++ optional ibusSupport ibus
+    ++ optional  openglSupport libGL
+    ++ optional  ibusSupport ibus
     ++ optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];
 
   # https://bugzilla.libsdl.org/show_bug.cgi?id=1431
@@ -81,6 +76,28 @@ stdenv.mkDerivation rec {
     moveToOutput bin/sdl2-config "$dev"
   '';
 
+  # SDL is weird in that instead of just dynamically linking with
+  # libraries when you `--enable-*` (or when `configure` finds) them
+  # it `dlopen`s them at runtime. In principle, this means it can
+  # ignore any missing optional dependencies like alsa, pulseaudio,
+  # some x11 libs, wayland, etc if they are missing on the system
+  # and/or work with wide array of versions of said libraries. In
+  # nixpkgs, however, we don't need any of that. Moreover, since we
+  # don't have a global ld-cache we have to stuff all the propagated
+  # libraries into rpath by hand or else some applications that use
+  # SDL API that requires said libraries will fail to start.
+  #
+  # You can grep SDL sources with `grep -rE 'SDL_(NAME|.*_SYM)'` to
+  # confirm that they actually use most of the `propagatedBuildInputs`
+  # from above in this way. This is pretty weird.
+  postFixup = ''
+    for lib in $out/lib/*.so* ; do
+      if [[ -L "$lib" ]]; then
+        patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath propagatedBuildInputs}" "$lib"
+      fi
+    done
+  '';
+
   setupHook = ./setup-hook.sh;
 
   passthru = { inherit openglSupport; };