From b47327ebd535468f71bbf6a46366e0bd9357b599 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Mon, 22 Aug 2016 06:24:00 +0300 Subject: [PATCH] SDL: cleanup and add patch to discover extensions --- pkgs/development/libraries/SDL/default.nix | 28 +++++++++---------- .../libraries/SDL/find-headers.patch | 16 +++++++++++ pkgs/development/libraries/SDL/setup-hook.sh | 11 ++++++++ .../development/libraries/SDL_gfx/default.nix | 24 ++++++---------- .../libraries/SDL_image/default.nix | 14 ++-------- .../libraries/SDL_mixer/default.nix | 18 ++---------- .../development/libraries/SDL_net/default.nix | 19 ++++--------- .../libraries/SDL_sound/default.nix | 13 +++++---- .../libraries/SDL_stretch/default.nix | 13 +++++---- pkgs/top-level/all-packages.nix | 4 +-- 10 files changed, 75 insertions(+), 85 deletions(-) create mode 100644 pkgs/development/libraries/SDL/find-headers.patch create mode 100644 pkgs/development/libraries/SDL/setup-hook.sh diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index 6c3920ff8aa8..ca0bbd6a01cf 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -1,8 +1,8 @@ { stdenv, fetchurl, fetchpatch, pkgconfig, audiofile, libcap -, openglSupport ? false, mesa ? null -, alsaSupport ? true, alsaLib ? null -, x11Support ? true, xlibsWrapper ? null, libXrandr ? null -, pulseaudioSupport ? true, libpulseaudio ? null +, openglSupport ? false, mesa_noglu +, alsaSupport ? true, alsaLib +, x11Support ? true, libXext, libICE, libXrandr +, pulseaudioSupport ? true, libpulseaudio , OpenGL, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa }: @@ -10,17 +10,12 @@ # PulseAudio. assert (stdenv.isLinux && !(stdenv ? cross)) -> alsaSupport || pulseaudioSupport; -assert openglSupport -> (mesa != null && x11Support); -assert x11Support -> (xlibsWrapper != null && libXrandr != null); -assert alsaSupport -> alsaLib != null; -assert pulseaudioSupport -> libpulseaudio != null; - let inherit (stdenv.lib) optional optionals; in stdenv.mkDerivation rec { - version = "1.2.15"; name = "SDL-${version}"; + version = "1.2.15"; src = fetchurl { url = "http://www.libsdl.org/release/${name}.tar.gz"; @@ -34,10 +29,10 @@ stdenv.mkDerivation rec { # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated. propagatedBuildInputs = - optionals x11Support [ xlibsWrapper libXrandr ] ++ + optionals x11Support [ libXext libICE libXrandr ] ++ optional alsaSupport alsaLib ++ optional stdenv.isLinux libcap ++ - optional openglSupport mesa ++ + optional openglSupport mesa_noglu ++ optional pulseaudioSupport libpulseaudio ++ optional stdenv.isDarwin Cocoa; @@ -57,9 +52,9 @@ stdenv.mkDerivation rec { "--enable-rpath" "--disable-pulseaudio-shared" "--disable-osmesa-shared" - ] ++ stdenv.lib.optionals (stdenv ? cross) ([ + ] ++ optionals (stdenv ? cross) ([ "--without-x" - ] ++ stdenv.lib.optional alsaSupport "--with-alsa-prefix=${alsaLib.out}/lib"); + ] ++ optional alsaSupport "--with-alsa-prefix=${alsaLib.out}/lib"); patches = [ # Fix window resizing issues, e.g. for xmonad @@ -95,15 +90,18 @@ stdenv.mkDerivation rec { url = "http://hg.libsdl.org/SDL/raw-rev/bbfb41c13a87"; sha256 = "1336g7waaf1c8yhkz11xbs500h8bmvabh4h437ax8l1xdwcppfxv"; }) + ./find-headers.patch ]; postFixup = ''moveToOutput share/aclocal "$dev" ''; + setupHook = ./setup-hook.sh; + passthru = { inherit openglSupport; }; meta = with stdenv.lib; { description = "A cross-platform multimedia library"; - homepage = http://www.libsdl.org/; + homepage = "http://www.libsdl.org/"; maintainers = with maintainers; [ lovek323 ]; platforms = platforms.unix; license = licenses.lgpl21; diff --git a/pkgs/development/libraries/SDL/find-headers.patch b/pkgs/development/libraries/SDL/find-headers.patch new file mode 100644 index 000000000000..5f75ae9e8301 --- /dev/null +++ b/pkgs/development/libraries/SDL/find-headers.patch @@ -0,0 +1,16 @@ +diff -ru3 SDL-1.2.15/sdl-config.in SDL-1.2.15-new/sdl-config.in +--- SDL-1.2.15/sdl-config.in 2012-01-19 10:30:06.000000000 +0400 ++++ SDL-1.2.15-new/sdl-config.in 2016-08-22 05:32:52.716397920 +0300 +@@ -42,7 +42,11 @@ + echo @SDL_VERSION@ + ;; + --cflags) +- echo -I@includedir@/SDL @SDL_CFLAGS@ ++ SDL_CFLAGS="" ++ for i in @includedir@/SDL $SDL_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/pkgs/development/libraries/SDL/setup-hook.sh b/pkgs/development/libraries/SDL/setup-hook.sh new file mode 100644 index 000000000000..3696e743a07a --- /dev/null +++ b/pkgs/development/libraries/SDL/setup-hook.sh @@ -0,0 +1,11 @@ +addSDLPath () { + if [ -e "$1/include/SDL" ]; then + export SDL_PATH="$SDL_PATH $1/include/SDL" + fi +} + +if test -n "$crossConfig"; then + crossEnvHooks+=(addSDLPath) +else + envHooks+=(addSDLPath) +fi diff --git a/pkgs/development/libraries/SDL_gfx/default.nix b/pkgs/development/libraries/SDL_gfx/default.nix index 7bff348b7543..ff8c081af93b 100644 --- a/pkgs/development/libraries/SDL_gfx/default.nix +++ b/pkgs/development/libraries/SDL_gfx/default.nix @@ -1,7 +1,8 @@ -{stdenv, fetchurl, SDL} : +{ stdenv, fetchurl, SDL }: stdenv.mkDerivation rec { - name = "SDL_gfx-2.0.25"; + name = "SDL_gfx-${version}"; + version = "2.0.25"; src = fetchurl { url = "http://www.ferzkopp.net/Software/SDL_gfx-2.0/${name}.tar.gz"; @@ -10,16 +11,9 @@ stdenv.mkDerivation rec { buildInputs = [ SDL ] ; - configureFlags = "--disable-mmx"; + configureFlags = [ "--disable-mmx" ]; - postInstall = '' - sed -i -e 's,"SDL.h",,' \ - $out/include/SDL/*.h - - ln -s $out/include/SDL/*.h $out/include/; - ''; - - meta = { + meta = with stdenv.lib; { description = "SDL graphics drawing primitives and support functions"; longDescription = @@ -40,10 +34,10 @@ stdenv.mkDerivation rec { code. Its is written in plain C and can be used in C++ code. ''; - homepage = https://sourceforge.net/projects/sdlgfx/; - license = stdenv.lib.licenses.lgpl2Plus; + homepage = "https://sourceforge.net/projects/sdlgfx/"; + license = licenses.zlib; - maintainers = [ stdenv.lib.maintainers.bjg ]; - platforms = stdenv.lib.platforms.unix; + maintainers = with maintainers; [ bjg ]; + platforms = platforms.unix; }; } diff --git a/pkgs/development/libraries/SDL_image/default.nix b/pkgs/development/libraries/SDL_image/default.nix index a1d839504770..62af47807cc2 100644 --- a/pkgs/development/libraries/SDL_image/default.nix +++ b/pkgs/development/libraries/SDL_image/default.nix @@ -1,7 +1,8 @@ { stdenv, fetchurl, SDL, libpng, libjpeg, libtiff, libungif, libXpm }: stdenv.mkDerivation rec { - name = "SDL_image-1.2.12"; + name = "SDL_image-${version}"; + version = "1.2.12"; src = fetchurl { url = "http://www.libsdl.org/projects/SDL_image/release/${name}.tar.gz"; @@ -10,18 +11,9 @@ stdenv.mkDerivation rec { buildInputs = [ SDL libpng libjpeg libtiff libungif libXpm ]; - postInstall = '' - sed -i -e 's,"SDL.h",,' \ - -e 's,"SDL_version.h",,' \ - -e 's,"begin_code.h",,' \ - -e 's,"close_code.h",,' \ - $out/include/SDL/SDL_image.h - ln -sv SDL/SDL_image.h $out/include/SDL_image.h - ''; - meta = with stdenv.lib; { description = "SDL image library"; - homepage = http://www.libsdl.org/projects/SDL_image/; + homepage = "http://www.libsdl.org/projects/SDL_image/"; maintainers = with maintainers; [ lovek323 ]; platforms = platforms.unix; }; diff --git a/pkgs/development/libraries/SDL_mixer/default.nix b/pkgs/development/libraries/SDL_mixer/default.nix index 2db10eeea764..d3d57947464b 100644 --- a/pkgs/development/libraries/SDL_mixer/default.nix +++ b/pkgs/development/libraries/SDL_mixer/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, SDL, libogg, libvorbis, smpeg, enableNativeMidi ? false, fluidsynth ? null }: +{ stdenv, lib, fetchurl, SDL, libogg, libvorbis, smpeg, enableNativeMidi ? false, fluidsynth ? null }: stdenv.mkDerivation rec { pname = "SDL_mixer"; @@ -10,21 +10,9 @@ stdenv.mkDerivation rec { sha256 = "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"; }; - buildInputs = [SDL libogg libvorbis fluidsynth smpeg]; + buildInputs = [ SDL libogg libvorbis fluidsynth smpeg ]; - configureFlags = "--disable-music-ogg-shared" + stdenv.lib.optionalString enableNativeMidi " --enable-music-native-midi-gpl"; - - postInstall = '' - ln -s $out/include/SDL/SDL_mixer.h $out/include/ - - for f in $out/include/SDL/SDL_mixer.h - do - for i in SDL_types.h SDL_rwops.h SDL_audio.h SDL_endian.h SDL_version.h begin_code.h close_code.h - do - substituteInPlace $f --replace "#include \"$i\"" "#include " - done - done - ''; + configureFlags = [ "--disable-music-ogg-shared" ] ++ lib.optional enableNativeMidi " --enable-music-native-midi-gpl"; meta = with stdenv.lib; { description = "SDL multi-channel audio mixer library"; diff --git a/pkgs/development/libraries/SDL_net/default.nix b/pkgs/development/libraries/SDL_net/default.nix index 045ad8925d90..b151d0ee83ee 100644 --- a/pkgs/development/libraries/SDL_net/default.nix +++ b/pkgs/development/libraries/SDL_net/default.nix @@ -11,21 +11,12 @@ stdenv.mkDerivation rec { sha256 = "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"; }; - propagatedBuildInputs = [SDL]; + propagatedBuildInputs = [ SDL ]; - postInstall = '' - sed -i -e 's,"SDL.h",,' \ - -e 's,"SDL_endian.h",,' \ - -e 's,"SDL_version.h",,' \ - -e 's,"begin_code.h",,' \ - -e 's,"close_code.h",,' \ - $out/include/SDL/SDL_net.h - - ln -sv $out/include/SDL/SDL_net.h $out/include/ - ''; - - meta = { + meta = with stdenv.lib; { description = "SDL networking library"; - platforms = stdenv.lib.platforms.unix; + platforms = platforms.unix; + license = licenses.zlib; + homepage = "https://www.libsdl.org/projects/SDL_net/release-1.2.html"; }; } diff --git a/pkgs/development/libraries/SDL_sound/default.nix b/pkgs/development/libraries/SDL_sound/default.nix index 5ca64730f517..8d088b6bbf47 100644 --- a/pkgs/development/libraries/SDL_sound/default.nix +++ b/pkgs/development/libraries/SDL_sound/default.nix @@ -1,7 +1,8 @@ -{stdenv, fetchurl, SDL, libvorbis, flac, libmikmod}: +{ stdenv, fetchurl, SDL, libvorbis, flac, libmikmod }: stdenv.mkDerivation rec { - name = "SDL_sound-1.0.3"; + name = "SDL_sound-${version}"; + version = "1.0.3"; src = fetchurl { url = "http://icculus.org/SDL_sound/downloads/${name}.tar.gz"; @@ -10,10 +11,10 @@ stdenv.mkDerivation rec { buildInputs = [ SDL libvorbis flac libmikmod ]; - postInstall = "ln -s $out/include/SDL/SDL_sound.h $out/include/"; - - meta = { + meta = with stdenv.lib; { description = "SDL sound library"; - platforms = stdenv.lib.platforms.linux; + platforms = platforms.linux; + license = licenses.lgpl21; + homepage = "https://www.icculus.org/SDL_sound/"; }; } diff --git a/pkgs/development/libraries/SDL_stretch/default.nix b/pkgs/development/libraries/SDL_stretch/default.nix index 52c43da9d16e..2a4ddac524c2 100644 --- a/pkgs/development/libraries/SDL_stretch/default.nix +++ b/pkgs/development/libraries/SDL_stretch/default.nix @@ -1,19 +1,20 @@ { stdenv, fetchurl, SDL }: -stdenv.mkDerivation { - name = "SDL_stretch-0.3.1"; +stdenv.mkDerivation rec { + name = "SDL_stretch-${version}"; + version = "0.3.1"; src = fetchurl { - url = "mirror://sourceforge/sdl-stretch/0.3.1/SDL_stretch-0.3.1.tar.bz2"; + url = "mirror://sourceforge/sdl-stretch/${version}/${name}.tar.bz2"; sha256 = "1mzw68sn4yxbp8429jg2h23h8xw2qjid51z1f5pdsghcn3x0pgvw"; }; buildInputs = [ SDL ]; - meta = { + meta = with stdenv.lib; { description = "Stretch Functions For SDL"; homepage = "http://sdl-stretch.sourceforge.net/"; - license = stdenv.lib.licenses.lgpl2; - platforms = stdenv.lib.platforms.linux; + license = licenses.lgpl2; + platforms = platforms.linux; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ab926db46a11..c47c06e943af 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9327,9 +9327,7 @@ in openglSupport = mesaSupported; alsaSupport = stdenv.isLinux; x11Support = !stdenv.isCygwin; - pulseaudioSupport = if (config ? pulseaudio) - then config.pulseaudio - else stdenv.isLinux; + pulseaudioSupport = config.pulseaudio or stdenv.isLinux; inherit (darwin.apple_sdk.frameworks) OpenGL CoreAudio CoreServices AudioUnit Kernel Cocoa; };