Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / smpeg / default.nix
blob099a3d838bbbc08775c406b315fea9befda2a25a
1 { lib, stdenv, fetchFromGitHub, fetchpatch, SDL, autoconf, automake, libtool, gtk2, m4, pkg-config, libGLU, libGL, makeWrapper }:
3 stdenv.mkDerivation rec {
4   pname = "smpeg";
5   version = "0.4.5";
7   src = fetchFromGitHub {
8     owner = "icculus";
9     repo = "smpeg";
10     rev = "release_${builtins.replaceStrings ["."] ["_"] version}";
11     sha256 = "sha256-nq/i7cFGpJXIuTwN/ScLMX7FN8NMdgdsRM9xOD3uycs=";
12   };
14   patches = [
15     ./format.patch
16     ./gcc6.patch
17     ./libx11.patch
18     ./gtk.patch
19     # These patches remove use of the `register` storage class specifier,
20     # allowing smpeg to build with clang 16, which defaults to C++17.
21     (fetchpatch {
22       url = "https://github.com/icculus/smpeg/commit/cc114ba0dd8644c0d6205bbce2384781daeff44b.patch";
23       hash = "sha256-GxSD82j05pw0r2SxmPYAe/BXX4iUc+iHWhB9Ap4GzfA=";
24     })
25     (fetchpatch {
26       url = "https://github.com/icculus/smpeg/commit/b369feca5bf99d6cff50d8eb316395ef48acf24f.patch";
27       hash = "sha256-U+a6dbc5cm249KlUcf4vi79yUiT4hgEvMv522K4PqUc=";
28     })
29   ];
31   postPatch = ''
32     substituteInPlace video/gdith.cpp \
33       --replace 'register int' 'int' \
34       --replace 'register Uint16' 'Uint16'
35   '';
37   enableParallelBuilding = true;
39   nativeBuildInputs = [ autoconf automake libtool m4 pkg-config makeWrapper ];
41   buildInputs = [ SDL ] ++ lib.optionals (!stdenv.isDarwin) [ gtk2 libGLU libGL ];
43   outputs = [ "out" "dev" ];
45   preConfigure = ''
46     touch NEWS AUTHORS ChangeLog
47     sh autogen.sh
48   '';
50   postInstall = ''
51     sed -i -e 's,"SDL.h",<SDL/SDL.h>,' \
52     -e 's,"SDL_mutex.h",<SDL/SDL_mutex.h>,' \
53     -e 's,"SDL_audio.h",<SDL/SDL_audio.h>,' \
54     -e 's,"SDL_thread.h",<SDL/SDL_thread.h>,' \
55     -e 's,"SDL_types.h",<SDL/SDL_types.h>,' \
56       $dev/include/smpeg/*.h
58     moveToOutput bin/smpeg-config "$dev"
60     wrapProgram $dev/bin/smpeg-config \
61       --prefix PATH ":" "${pkg-config}/bin" \
62       --prefix PKG_CONFIG_PATH ":" "${lib.getDev SDL}/lib/pkgconfig"
63   '';
65   NIX_LDFLAGS = "-lX11";
67   meta = {
68     homepage = "http://icculus.org/smpeg/";
69     description = "MPEG decoding library";
70     license = lib.licenses.gpl2Plus;
71     platforms = lib.platforms.unix;
72   };