diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/libraries/SDL2 | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/SDL2')
3 files changed, 144 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/SDL2/default.nix b/nixpkgs/pkgs/development/libraries/SDL2/default.nix new file mode 100644 index 000000000000..e009204133ef --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/SDL2/default.nix @@ -0,0 +1,111 @@ +{ stdenv, config, libGLSupported, fetchurl, pkgconfig, pruneLibtoolFiles +, openglSupport ? libGLSupported, libGL +, alsaSupport ? stdenv.isLinux, alsaLib +, x11Support ? !stdenv.isCygwin, libX11, xproto, libICE, libXi, libXScrnSaver, libXcursor, libXinerama, libXext, libXxf86vm, libXrandr +, waylandSupport ? stdenv.isLinux, wayland, wayland-protocols, libxkbcommon +, dbusSupport ? stdenv.isLinux, dbus +, udevSupport ? false, udev +, ibusSupport ? false, ibus +, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio +, AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL +, audiofile, cf-private, libiconv +}: + +# NOTE: When editing this expression see if the same change applies to +# SDL expression too + +with stdenv.lib; + +assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport; +assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null); + +stdenv.mkDerivation rec { + name = "SDL2-${version}"; + version = "2.0.9"; + + src = fetchurl { + url = "https://www.libsdl.org/release/${name}.tar.gz"; + sha256 = "1c94ndagzkdfqaa838yqg589p1nnqln8mv0hpwfhrkbfczf8cl95"; + }; + + outputs = [ "out" "dev" ]; + outputBin = "dev"; # sdl-config + + patches = [ ./find-headers.patch ]; + + nativeBuildInputs = [ pkgconfig pruneLibtoolFiles ]; + + 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. + ++ optionals x11Support [ libX11 xproto ]; + + dlopenBuildInputs = [ ] + ++ optional alsaSupport alsaLib + ++ optional dbusSupport dbus + ++ optional pulseaudioSupport libpulseaudio + ++ optional udevSupport udev + ++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ] + ++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]; + + buildInputs = [ audiofile libiconv ] + ++ dlopenBuildInputs + ++ optional ibusSupport ibus + ++ optionals stdenv.isDarwin [ + AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL + # Needed for NSDefaultRunLoopMode symbols. + cf-private + ]; + + enableParallelBuilding = true; + + configureFlags = [ + "--disable-oss" + ] ++ optional (!x11Support) "--without-x" + ++ optional alsaSupport "--with-alsa-prefix=${alsaLib.out}/lib" + ++ optional stdenv.isDarwin "--disable-sdltest"; + + postInstall = '' + moveToOutput lib/libSDL2main.a "$dev" + rm $out/lib/*.a + 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 + # list the symbols used in this way. + postFixup = let + rpath = makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs); + in optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so") '' + for lib in $out/lib/*.so* ; do + if ! [[ -L "$lib" ]]; then + patchelf --set-rpath "$(patchelf --print-rpath $lib):${rpath}" "$lib" + fi + done + ''; + + setupHook = ./setup-hook.sh; + + passthru = { inherit openglSupport; }; + + meta = with stdenv.lib; { + description = "A cross-platform multimedia library"; + homepage = http://www.libsdl.org/; + license = licenses.zlib; + platforms = platforms.all; + maintainers = with maintainers; [ cpages ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/SDL2/find-headers.patch b/nixpkgs/pkgs/development/libraries/SDL2/find-headers.patch new file mode 100644 index 000000000000..a6114901055a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/SDL2/find-headers.patch @@ -0,0 +1,26 @@ +diff -ru3 SDL2-2.0.4/sdl2-config.cmake.in SDL2-2.0.4-new/sdl2-config.cmake.in +--- SDL2-2.0.4/sdl2-config.cmake.in 2016-01-02 22:56:31.000000000 +0300 ++++ SDL2-2.0.4-new/sdl2-config.cmake.in 2016-08-22 05:26:42.420397323 +0300 +@@ -6,5 +6,5 @@ + set(SDL2_PREFIX "@prefix@") + set(SDL2_EXEC_PREFIX "@prefix@") + set(SDL2_LIBDIR "@libdir@") +-set(SDL2_INCLUDE_DIRS "@includedir@/SDL2") ++set(SDL2_INCLUDE_DIRS "@includedir@/SDL2" $ENV{SDL2_PATH}) + set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@") +diff -ru3 SDL2-2.0.4/sdl2-config.in SDL2-2.0.4-new/sdl2-config.in +--- SDL2-2.0.4/sdl2-config.in 2016-01-02 22:56:31.000000000 +0300 ++++ SDL2-2.0.4-new/sdl2-config.in 2016-08-22 05:32:02.256397839 +0300 +@@ -42,7 +42,11 @@ + echo @SDL_VERSION@ + ;; + --cflags) +- echo -I@includedir@/SDL2 @SDL_CFLAGS@ ++ SDL_CFLAGS="" ++ for i in @includedir@/SDL2 $SDL2_PATH; do ++ SDL_CFLAGS="$SDL_CFLAGS -I$i" ++ done ++ echo $SDL_CFLAGS @SDL_CFLAGS@ + ;; + @ENABLE_SHARED_TRUE@ --libs) + @ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@ diff --git a/nixpkgs/pkgs/development/libraries/SDL2/setup-hook.sh b/nixpkgs/pkgs/development/libraries/SDL2/setup-hook.sh new file mode 100644 index 000000000000..3acce9d473c5 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/SDL2/setup-hook.sh @@ -0,0 +1,7 @@ +addSDL2Path () { + if [ -e "$1/include/SDL2" ]; then + export SDL2_PATH="$SDL2_PATH $1/include/SDL2" + fi +} + +addEnvHooks "$hostOffset" addSDL2Path |