2019-05-28 19:52:34 +01:00
|
|
|
{ stdenv, config, fetchurl, pkgconfig
|
|
|
|
, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
|
2018-11-05 11:55:08 +00:00
|
|
|
, openglSupport ? libGLSupported, libGL
|
2019-02-22 15:36:48 +00:00
|
|
|
, alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib
|
|
|
|
, x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
|
|
|
|
, libX11, xorgproto, libICE, libXi, libXScrnSaver, libXcursor
|
|
|
|
, libXinerama, libXext, libXxf86vm, libXrandr
|
|
|
|
, waylandSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid
|
|
|
|
, wayland, wayland-protocols, libxkbcommon
|
|
|
|
, dbusSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, dbus
|
2016-08-22 04:24:32 +01:00
|
|
|
, udevSupport ? false, udev
|
|
|
|
, ibusSupport ? false, ibus
|
2019-05-06 04:51:09 +01:00
|
|
|
, fcitxSupport ? false, fcitx
|
2019-02-22 15:36:48 +00:00
|
|
|
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid
|
|
|
|
, libpulseaudio
|
2015-10-28 19:34:57 +00:00
|
|
|
, AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL
|
SDL2: include cf-private on darwin
It's not included implicitly by the frameworks anymore.
Undefined symbols for architecture x86_64:
"_NSDefaultRunLoopMode", referenced from:
_Cocoa_PumpEvents in SDL_cocoaevents.o
"_NSURLIsAliasFileKey", referenced from:
-[SDLWindow performDragOperation:] in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSArray", referenced from:
objc-class-ref in SDL_cocoaclipboard.o
objc-class-ref in SDL_cocoakeyboard.o
objc-class-ref in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSData", referenced from:
objc-class-ref in SDL_cocoamouse.o
"_OBJC_CLASS_$_NSDate", referenced from:
objc-class-ref in SDL_cocoaevents.o
"_OBJC_CLASS_$_NSDictionary", referenced from:
objc-class-ref in SDL_cocoaevents.o
"_OBJC_CLASS_$_NSMutableArray", referenced from:
objc-class-ref in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSURL", referenced from:
objc-class-ref in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSUserDefaults", referenced from:
objc-class-ref in SDL_cocoaevents.o
"_OBJC_EHTYPE_$_NSException", referenced from:
GCC_except_table67 in SDL_cocoawindow.o
ld: symbol(s) not found for architecture x86_64
2018-11-05 11:22:11 +00:00
|
|
|
, audiofile, cf-private, libiconv
|
2013-07-02 22:06:05 +01:00
|
|
|
}:
|
|
|
|
|
2018-03-05 17:30:34 +00:00
|
|
|
# NOTE: When editing this expression see if the same change applies to
|
|
|
|
# SDL expression too
|
|
|
|
|
2018-11-05 11:55:08 +00:00
|
|
|
with stdenv.lib;
|
2013-07-02 22:06:05 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2016-08-22 04:24:32 +01:00
|
|
|
name = "SDL2-${version}";
|
2018-11-04 00:28:17 +00:00
|
|
|
version = "2.0.9";
|
2013-07-02 22:06:05 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2018-06-28 19:43:35 +01:00
|
|
|
url = "https://www.libsdl.org/release/${name}.tar.gz";
|
2018-11-04 00:28:17 +00:00
|
|
|
sha256 = "1c94ndagzkdfqaa838yqg589p1nnqln8mv0hpwfhrkbfczf8cl95";
|
2013-07-02 22:06:05 +01:00
|
|
|
};
|
|
|
|
|
2016-12-25 01:11:07 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
2018-03-05 17:30:34 +00:00
|
|
|
outputBin = "dev"; # sdl-config
|
2016-12-25 01:11:07 +00:00
|
|
|
|
2016-08-22 04:24:32 +01:00
|
|
|
patches = [ ./find-headers.patch ];
|
|
|
|
|
2018-12-09 22:55:10 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2016-08-22 04:24:32 +01:00
|
|
|
|
2018-06-10 23:29:24 +01:00
|
|
|
propagatedBuildInputs = dlopenPropagatedBuildInputs;
|
|
|
|
|
|
|
|
dlopenPropagatedBuildInputs = [ ]
|
|
|
|
# Propagated for #include <GLES/gl.h> in SDL_opengles.h.
|
|
|
|
++ optional openglSupport libGL
|
|
|
|
# Propagated for #include <X11/Xlib.h> and <X11/Xatom.h> in SDL_syswm.h.
|
2018-12-31 03:40:47 +00:00
|
|
|
++ optionals x11Support [ libX11 xorgproto ];
|
2018-06-10 23:29:24 +01:00
|
|
|
|
|
|
|
dlopenBuildInputs = [ ]
|
2019-02-22 15:36:48 +00:00
|
|
|
++ optionals alsaSupport [ alsaLib audiofile ]
|
2018-03-05 20:12:44 +00:00
|
|
|
++ optional dbusSupport dbus
|
2018-06-10 23:29:24 +01:00
|
|
|
++ optional pulseaudioSupport libpulseaudio
|
2018-03-05 20:12:44 +00:00
|
|
|
++ optional udevSupport udev
|
2018-03-05 17:30:34 +00:00
|
|
|
++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
|
2018-06-10 23:29:24 +01:00
|
|
|
++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ];
|
2013-07-02 22:06:05 +01:00
|
|
|
|
2019-02-22 15:36:48 +00:00
|
|
|
buildInputs = [ libiconv ]
|
2018-06-10 23:29:24 +01:00
|
|
|
++ dlopenBuildInputs
|
2018-03-05 20:12:44 +00:00
|
|
|
++ optional ibusSupport ibus
|
2019-05-06 04:51:09 +01:00
|
|
|
++ optional fcitxSupport fcitx
|
SDL2: include cf-private on darwin
It's not included implicitly by the frameworks anymore.
Undefined symbols for architecture x86_64:
"_NSDefaultRunLoopMode", referenced from:
_Cocoa_PumpEvents in SDL_cocoaevents.o
"_NSURLIsAliasFileKey", referenced from:
-[SDLWindow performDragOperation:] in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSArray", referenced from:
objc-class-ref in SDL_cocoaclipboard.o
objc-class-ref in SDL_cocoakeyboard.o
objc-class-ref in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSData", referenced from:
objc-class-ref in SDL_cocoamouse.o
"_OBJC_CLASS_$_NSDate", referenced from:
objc-class-ref in SDL_cocoaevents.o
"_OBJC_CLASS_$_NSDictionary", referenced from:
objc-class-ref in SDL_cocoaevents.o
"_OBJC_CLASS_$_NSMutableArray", referenced from:
objc-class-ref in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSURL", referenced from:
objc-class-ref in SDL_cocoawindow.o
"_OBJC_CLASS_$_NSUserDefaults", referenced from:
objc-class-ref in SDL_cocoaevents.o
"_OBJC_EHTYPE_$_NSException", referenced from:
GCC_except_table67 in SDL_cocoawindow.o
ld: symbol(s) not found for architecture x86_64
2018-11-05 11:22:11 +00:00
|
|
|
++ optionals stdenv.isDarwin [
|
|
|
|
AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL
|
|
|
|
# Needed for NSDefaultRunLoopMode symbols.
|
|
|
|
cf-private
|
|
|
|
];
|
2013-11-06 22:17:46 +00:00
|
|
|
|
2018-11-13 16:41:39 +00:00
|
|
|
enableParallelBuilding = true;
|
2017-02-16 21:24:40 +00:00
|
|
|
|
2018-05-10 17:31:03 +01:00
|
|
|
configureFlags = [
|
|
|
|
"--disable-oss"
|
|
|
|
] ++ optional (!x11Support) "--without-x"
|
2018-06-07 00:18:00 +01:00
|
|
|
++ optional alsaSupport "--with-alsa-prefix=${alsaLib.out}/lib"
|
|
|
|
++ optional stdenv.isDarwin "--disable-sdltest";
|
2013-07-02 22:06:05 +01:00
|
|
|
|
2013-11-06 22:17:46 +00:00
|
|
|
postInstall = ''
|
2017-02-16 21:24:40 +00:00
|
|
|
moveToOutput lib/libSDL2main.a "$dev"
|
2013-11-06 22:17:46 +00:00
|
|
|
rm $out/lib/*.a
|
2016-12-25 01:11:07 +00:00
|
|
|
moveToOutput bin/sdl2-config "$dev"
|
2013-11-06 22:17:46 +00:00
|
|
|
'';
|
|
|
|
|
2018-03-05 20:12:44 +00:00
|
|
|
# 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
|
2018-06-10 23:29:24 +01:00
|
|
|
# list the symbols used in this way.
|
|
|
|
postFixup = let
|
|
|
|
rpath = makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
|
|
|
|
in optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
|
2018-03-05 20:12:44 +00:00
|
|
|
for lib in $out/lib/*.so* ; do
|
2018-06-10 23:25:33 +01:00
|
|
|
if ! [[ -L "$lib" ]]; then
|
2018-06-10 23:29:24 +01:00
|
|
|
patchelf --set-rpath "$(patchelf --print-rpath $lib):${rpath}" "$lib"
|
2018-03-05 20:12:44 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2016-08-22 04:24:32 +01:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
passthru = { inherit openglSupport; };
|
2013-07-02 22:06:05 +01:00
|
|
|
|
2016-08-22 04:24:32 +01:00
|
|
|
meta = with stdenv.lib; {
|
2013-07-02 22:06:05 +01:00
|
|
|
description = "A cross-platform multimedia library";
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = http://www.libsdl.org/;
|
2016-08-22 04:24:32 +01:00
|
|
|
license = licenses.zlib;
|
|
|
|
platforms = platforms.all;
|
2017-01-20 11:23:57 +00:00
|
|
|
maintainers = with maintainers; [ cpages ];
|
2013-07-02 22:06:05 +01:00
|
|
|
};
|
|
|
|
}
|